pub fn fundamental_cycles(
graph: &Graph,
start_vid: Option<VertexId>,
bfs_cutoff: Option<u32>,
) -> IgraphResult<Vec<Vec<u32>>>Expand description
Compute the fundamental cycle basis of a graph.
Returns a list of cycles, where each cycle is a Vec<EdgeId>
listing the edge IDs forming that cycle. The cycle basis is
associated with a BFS tree rooted at each connected component.
If start_vid is Some(v), only the component containing v
is processed. If None, all components are processed.
If bfs_cutoff is Some(k), only cycles of length at most
2*k + 1 are returned. If None, all fundamental cycles are
found.
Edge directions are ignored (the graph is treated as undirected).
§Errors
Returns an error if start_vid is out of range.
§Examples
use rust_igraph::{Graph, fundamental_cycles};
// Triangle: one fundamental cycle of length 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();
let cycles = fundamental_cycles(&g, None, None).unwrap();
assert_eq!(cycles.len(), 1);
assert_eq!(cycles[0].len(), 3);
// Tree: no cycles.
let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap();
g.add_edge(0, 2).unwrap();
g.add_edge(0, 3).unwrap();
let cycles = fundamental_cycles(&g, None, None).unwrap();
assert!(cycles.is_empty());