Skip to main content

degree_hierarchy

Function degree_hierarchy 

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

Compute the degree hierarchy (Gini coefficient of degrees).

The Gini coefficient measures inequality in the degree distribution. Values near 0 indicate all vertices have similar degree (regular graph); values near 1 indicate extreme inequality (star-like). Returns 0.0 for trivial or edgeless graphs.

§Examples

use rust_igraph::{Graph, degree_hierarchy};

// K_4: all degrees equal → Gini = 0.0
let g = Graph::from_edges(
    &[(0,1),(0,2),(0,3),(1,2),(1,3),(2,3)], false, Some(4)
).unwrap();
assert!(degree_hierarchy(&g).unwrap().abs() < 1e-10);