Skip to main content

self_loop_ratio

Function self_loop_ratio 

Source
pub fn self_loop_ratio(graph: &Graph) -> IgraphResult<f64>
Expand description

Compute the self-loop ratio of the graph.

Fraction of edges that are self-loops (edges where both endpoints are the same vertex). Returns 0.0 for graphs with no edges.

ยงExamples

use rust_igraph::{Graph, self_loop_ratio};

// No self-loops in a simple triangle
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert!(self_loop_ratio(&g).unwrap().abs() < 1e-10);