Skip to main content

degree_herfindahl

Function degree_herfindahl 

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

Compute the Herfindahl–Hirschman index of the degree sequence.

H = Σ_v (d(v) / Σ_u d(u))²

Measures concentration: 1/n for a regular graph (perfect equality), 1.0 for a star (one vertex holds all degree mass). Returns 0.0 for the empty or edgeless graph.

§Examples

use rust_igraph::{Graph, degree_herfindahl};

// K_3: all degrees 2, total 6 → 3·(2/6)² = 3·(1/9) = 1/3
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert!((degree_herfindahl(&g).unwrap() - 1.0/3.0).abs() < 1e-10);