Skip to main content

edge_degree_pearson

Function edge_degree_pearson 

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

Compute the Pearson correlation of endpoint degrees across edges.

The standard Pearson r between the two degree sequences formed by edge endpoints. Related to but not identical to degree_assortativity (Newman’s definition uses a different normalization).

Returns 0.0 for the empty graph or when variance is zero (regular graphs). Self-loops are skipped.

§Examples

use rust_igraph::{Graph, edge_degree_pearson};

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