Skip to main content

degree_gini

Function degree_gini 

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

Compute the Gini coefficient of the degree sequence.

Gini = (Σ_i Σ_j |d_i - d_j|) / (2 n² d̄)

Measures inequality: 0 = perfect equality (all degrees the same), approaching 1 = maximal inequality (star-like). Returns 0.0 for edgeless graphs (d̄ = 0) or single-vertex graphs.

§Examples

use rust_igraph::{Graph, degree_gini};

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