Skip to main content

degree_neighbor_correlation

Function degree_neighbor_correlation 

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

Compute the degree-neighbor correlation.

Pearson correlation between vertex degree and mean neighbor degree across all vertices with degree ≥ 1. Negative values indicate disassortative mixing (high-degree nodes connect to low-degree nodes). Returns 0.0 for trivial graphs or when variance is zero.

§Examples

use rust_igraph::{Graph, degree_neighbor_correlation};

// K_4: all degrees and mean-neighbor-degrees equal → 0.0
let g = Graph::from_edges(
    &[(0,1),(0,2),(0,3),(1,2),(1,3),(2,3)], false, Some(4)
).unwrap();
assert!(degree_neighbor_correlation(&g).unwrap().abs() < 1e-10);