pub fn asymmetric_preference_game(
nodes: u32,
no_out_types: u32,
no_in_types: u32,
type_dist_matrix: Option<&[Vec<f64>]>,
pref_matrix: &[Vec<f64>],
loops: bool,
seed: u64,
) -> IgraphResult<(Graph, Vec<u32>, Vec<u32>)>Expand description
Generate a random directed graph with asymmetric vertex types and connection preferences.
Each vertex is assigned an (out_type, in_type) pair drawn jointly
from type_dist_matrix (or uniformly when None). A directed edge
u → v is then sampled with probability
pref_matrix[out_type(u)][in_type(v)].
nodes— number of vertices.no_out_types,no_in_types— number of out- and in-types (≥ 1).type_dist_matrix—out_types × in_typesjoint weights;None⇒ uniform.pref_matrix—out_types × in_typesconnection probabilities in[0, 1].loops— allow self-loop edges.seed— initialises an internalSplitMix64PRNG.
The resulting graph is always directed.
§Returns
(graph, node_type_out, node_type_in) — the per-vertex out- and
in-type assignments.
§Errors
Returns IgraphError::InvalidArgument when:
no_out_types < 1orno_in_types < 1,type_dist_matrixhas wrong dimensions, NaN, or negative entries,pref_matrixhas wrong dimensions, NaN, or entries outside[0, 1],nodesexceeds the2^53f64-exact ceiling.
§Examples
use rust_igraph::asymmetric_preference_game;
// 2 out-types × 2 in-types, uniform mixing, p ≈ 0.1 across the board.
let pref = vec![vec![0.1, 0.1], vec![0.1, 0.1]];
let (g, out, inp) =
asymmetric_preference_game(40, 2, 2, None, &pref, true, 42).unwrap();
assert_eq!(g.vcount(), 40);
assert!(g.is_directed());
assert!(out.iter().all(|&t| t < 2));
assert!(inp.iter().all(|&t| t < 2));