pub fn assortativity_degree_directed_weighted(
graph: &Graph,
weights: &[f64],
) -> IgraphResult<Option<f64>>Expand description
Directed weighted degree assortativity (PR-006d).
Counterpart of igraph_assortativity_degree(_, _, /*directed=*/true, &weights) from references/igraph/src/misc/mixing.c:351-405. Pearson
correlation between out-strength of source and in-strength of target,
each edge weighted by w:
For each edge (u → v) with weight w:
num1 += w * (s_out[u] * s_in[v])
num2 += w * s_out[u]
num3 += w * s_in[v]
den1 += w * s_out[u]^2
den2 += w * s_in[v]^2
W = Σ w
r = (num1 - num2*num3/W) / (sqrt(den1 - num2^2/W) * sqrt(den2 - num3^2/W))Returns None for graphs with no edges, zero total weight, or zero
variance (matches upstream’s IGRAPH_NAN). Undirected graphs route
to the symmetric formula via assortativity_degree_weighted.
§Examples
use rust_igraph::{Graph, assortativity_degree_directed_weighted};
// Directed 3-cycle 0→1→2→0 with unit weights: every vertex has
// out-strength 1 and in-strength 1, so both variance terms vanish.
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_weighted(&g, &[1.0, 1.0, 1.0]).unwrap(),
None
);