pub fn assortativity_degree_directed(graph: &Graph) -> IgraphResult<Option<f64>>Expand description
Directed degree assortativity coefficient (ALGO-PR-006c).
Counterpart of igraph_assortativity_degree(_, _, /*directed=*/true)
(the directed branch of mixing.c:443). For each directed edge
e = (u → v) Pearson-correlates the source’s out-degree against
the target’s in-degree:
num1 = Σ out_deg(u) * in_deg(v)
num2 = Σ out_deg(u)
num3 = Σ in_deg(v)
den1 = Σ out_deg(u)²
den2 = Σ in_deg(v)²
num = num1 − num2 * num3 / m
den = sqrt(den1 − num2² / m) * sqrt(den2 − num3² / m)
r = num / den (None if den == 0)Returns None for graphs with no edges or where either variance
term collapses (regular in-degrees and/or regular out-degrees —
matches upstream NaN). Undirected graphs are accepted and route
to the undirected formula via assortativity_degree.
§Examples
use rust_igraph::{Graph, assortativity_degree_directed};
// Directed 3-cycle 0→1→2→0: every vertex has out-degree 1 and
// in-degree 1. Both variance terms vanish → None.
let mut g = Graph::new(3, true).unwrap();
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 0).unwrap();
assert_eq!(assortativity_degree_directed(&g).unwrap(), None);