pub fn count_loops(graph: &Graph) -> IgraphResult<usize>Expand description
Counts self-loop edges in graph.
A self-loop is an edge (v, v). Returns the total number of such
edges, counting parallel self-loops separately.
Counterpart of igraph_count_loops() from
references/igraph/src/properties/loops.c.
O(|E|) linear scan.
ยงExamples
use rust_igraph::{Graph, count_loops};
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 1).unwrap();
g.add_edge(2, 2).unwrap();
g.add_edge(2, 2).unwrap();
assert_eq!(count_loops(&g).unwrap(), 3);