Skip to main content

degree_variance

Function degree_variance 

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

Compute the variance of the degree sequence.

Var(G) = (1/n) Σ_{v∈V} (d_v − d̄)²

Where d̄ = 2m/n is the mean degree. Zero iff regular. This is a normalised irregularity measure.

§Examples

use rust_igraph::{Graph, degree_variance};

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