pub fn is_path(graph: &Graph) -> IgraphResult<bool>Expand description
Check whether a graph is a path graph.
A path graph P_n has n vertices connected in a single line:
0-1-2-..-(n-1). Every vertex has degree ≤ 2, and the graph is a
tree (connected, acyclic).
Returns false for directed graphs.
Returns true for the empty graph and single vertex (P_0, P_1).
§Examples
use rust_igraph::{Graph, is_path};
// P_4: 0-1-2-3
let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 3).unwrap();
assert!(is_path(&g).unwrap());
// Star K_{1,3} is NOT a path (center has degree 3)
let mut g = Graph::with_vertices(4);
for i in 1..4u32 {
g.add_edge(0, i).unwrap();
}
assert!(!is_path(&g).unwrap());