Skip to main content

degree_variance_ratio

Function degree_variance_ratio 

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

Compute the degree variance ratio.

Var(d) / Var_max where Var_max = (n-1)² · n / (4n) for simple undirected graphs (the variance of a star on n vertices). Simplifies to Var(d) · 4 / (n-1)². Returns 0.0 for graphs with fewer than 2 vertices.

§Examples

use rust_igraph::{Graph, degree_variance_ratio};

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