pub fn girth(graph: &Graph) -> IgraphResult<Option<u32>>Expand description
Shortest cycle length in graph. Returns None for acyclic graphs.
Self-loops and parallel edges are ignored — only “real” cycles of
length ≥ 3 are considered. Counterpart of igraph_girth(_, &girth, NULL)
where IGRAPH_INFINITY for acyclic maps to None.
Edge directions are ignored (IGRAPH_ALL semantics).
§Examples
use rust_igraph::{Graph, girth};
// Triangle: girth = 3.
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 0).unwrap();
assert_eq!(girth(&g).unwrap(), Some(3));
// Tree: no cycles.
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
assert_eq!(girth(&g).unwrap(), None);