Skip to main content

clustering_variance

Function clustering_variance 

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

Variance of local clustering coefficients.

Computes the population variance of the local clustering coefficients across all vertices with degree ≥ 2 (vertices with degree < 2 have undefined clustering coefficient and are excluded).

Returns 0.0 if fewer than 2 vertices have defined clustering coefficients.

§Examples

use rust_igraph::{Graph, clustering_variance};

// K4: all local CC = 1.0 → variance = 0
let g = Graph::from_edges(
    &[(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)],
    false,
    Some(4),
)
.unwrap();
assert!(clustering_variance(&g).unwrap().abs() < 1e-10);