Skip to main content

leaf_to_hub_ratio

Function leaf_to_hub_ratio 

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

Compute the leaf-to-hub ratio.

Number of degree-1 vertices divided by number of vertices whose degree exceeds the average. Returns 0.0 if there are no hub vertices or no leaves.

§Examples

use rust_igraph::{Graph, leaf_to_hub_ratio};

// Star S_5: 4 leaves, 1 hub (center d=4, avg=8/5=1.6) → 4/1 = 4.0
let g = Graph::from_edges(&[(0,1),(0,2),(0,3),(0,4)], false, Some(5)).unwrap();
assert!((leaf_to_hub_ratio(&g).unwrap() - 4.0).abs() < 1e-10);