Skip to main content

edge_degree_covariance

Function edge_degree_covariance 

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

Compute the degree covariance across edges.

Cov = (1/m) Σ_{(u,v)∈E} d(u)·d(v) - [(1/m) Σ d(u)]·[(1/m) Σ d(v)]

where each edge contributes a pair (d(u), d(v)). Positive covariance means high-degree vertices tend to connect to high-degree vertices (assortative). Returns 0.0 for the empty or single-edge graph. Self-loops are skipped.

§Examples

use rust_igraph::{Graph, edge_degree_covariance};

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