Skip to main content

degree_hoover

Function degree_hoover 

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

Compute the Hoover index (Robin Hood index) of the degree sequence.

H = Σ|d(v) - d̄| / (2 · Σd)

The maximum fraction of total degree that would need to be redistributed to achieve perfect equality. Ranges from 0 (regular graph) to (n-1)/n (star). Returns 0.0 for the empty or edgeless graph.

§Examples

use rust_igraph::{Graph, degree_hoover};

// K_3: all degrees 2, mean=2 → all |d-d̄|=0 → Hoover=0
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert!(degree_hoover(&g).unwrap().abs() < 1e-10);