Skip to main content

flow_hierarchy_ratio

Function flow_hierarchy_ratio 

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

Compute the flow hierarchy ratio.

Fraction of edges that would be in a minimum spanning tree (assuming unit weights, this equals (n-1)/m for connected graphs). Measures how tree-like the graph is. Values near 1 indicate a tree (all edges are bridges); values near 0 indicate a densely connected graph. Returns 0.0 for disconnected or trivial graphs.

§Examples

use rust_igraph::{Graph, flow_hierarchy_ratio};

// Tree (path 0-1-2-3): all edges in MST → (n-1)/m = 3/3 = 1.0
let g = Graph::from_edges(&[(0,1),(1,2),(2,3)], false, Some(4)).unwrap();
assert!((flow_hierarchy_ratio(&g).unwrap() - 1.0).abs() < 1e-10);