pub fn leaf_ratio(graph: &Graph) -> IgraphResult<f64>Expand description
Compute the leaf ratio.
Fraction of vertices with degree exactly 1 (pendant/leaf vertices). These are the most vulnerable vertices — removing their single edge isolates them. Returns 0.0 for empty or edgeless graphs.
§Examples
use rust_igraph::{Graph, leaf_ratio};
// Star_5: 4 leaves out of 5 vertices → 4/5
let g = Graph::from_edges(
&[(0,1),(0,2),(0,3),(0,4)], false, Some(5)
).unwrap();
assert!((leaf_ratio(&g).unwrap() - 4.0/5.0).abs() < 1e-10);