pub fn degree_correlation_vector(
graph: &Graph,
from_mode: DegreeMode,
to_mode: DegreeMode,
directed_neighbors: bool,
weights: Option<&[f64]>,
) -> IgraphResult<Vec<f64>>Expand description
Compute the degree correlation function k_nn(k).
For each degree value d, computes the weighted average degree of
vertices connected to by vertices of degree d. The result vector
is indexed by degree: result[d] = mean neighbor degree for source
degree d.
from_mode: how to measure source vertex degree (Out/In/All).to_mode: how to measure target vertex degree (Out/In/All).directed_neighbors: if true, only follow edge direction (u→v). If false, treat edges as reciprocal (both u→v and v→u counted). Ignored for undirected graphs.weights: optional edge weights. IfNone, all weights are 1.
Returns a vector of length max_from_degree + 1. Entries for
degrees with no edges will be f64::NAN.
§Examples
use rust_igraph::{Graph, DegreeMode, degree_correlation_vector};
// Star graph: center has degree 4, leaves have degree 1
let mut g = Graph::with_vertices(5);
g.add_edge(0, 1).unwrap();
g.add_edge(0, 2).unwrap();
g.add_edge(0, 3).unwrap();
g.add_edge(0, 4).unwrap();
let knnk = degree_correlation_vector(
&g, DegreeMode::All, DegreeMode::All, false, None,
).unwrap();
// k_nn(1) = 4.0 (leaves connect to center with deg 4)
assert!((knnk[1] - 4.0).abs() < 1e-10);
// k_nn(4) = 1.0 (center connects to leaves with deg 1)
assert!((knnk[4] - 1.0).abs() < 1e-10);