pub fn joint_type_distribution(
graph: &Graph,
from_types: &[u32],
to_types: Option<&[u32]>,
directed: bool,
normalized: bool,
weights: Option<&[f64]>,
) -> IgraphResult<Vec<Vec<f64>>>Expand description
Compute the joint type distribution (mixing matrix).
Given vertex type labels, produces a matrix where entry (i,j) is the
count (or probability, if normalized) of edges from type-i to type-j
vertices.
from_types: type label for source endpoint of each vertex (length = vcount).to_types: type label for target endpoint. IfNone, usesfrom_typesfor both endpoints.directed: if true and graph is directed, count each edge once (from→to); otherwise count each edge in both directions.normalized: if true, divide by total weight so entries sum to 1.weights: optional edge weights (length must equal ecount).
Returns a row-major matrix as Vec<Vec<f64>> with dimensions
(max_from_type+1) x (max_to_type+1).
§Examples
use rust_igraph::{Graph, joint_type_distribution};
let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap(); // type 0 - type 0
g.add_edge(2, 3).unwrap(); // type 1 - type 1
let types = vec![0u32, 0, 1, 1];
let m = joint_type_distribution(&g, &types, None, false, true, None).unwrap();
// Normalized undirected: [[0.5, 0], [0, 0.5]]
assert!((m[0][0] - 0.5).abs() < 1e-10);
assert!((m[1][1] - 0.5).abs() < 1e-10);
assert!((m[0][1]).abs() < 1e-10);