pub fn hsbm_game(
n: u32,
m: u32,
rho: &[f64],
c: &[Vec<f64>],
p: f64,
seed: u64,
) -> IgraphResult<Graph>Expand description
Generate a graph from the uniform Hierarchical Stochastic Block
Model: every macro-block is the same size m and shares the same
internal preference matrix.
n— total vertex count. Must satisfyn >= 1andn % m == 0.m— micro-vertex count per macro-block. Must satisfym >= 1. The number of macro-blocks isn / m.rho— micro-block proportions inside each macro-block. Lengthk, entries in[0, 1], sum equal to1within√DBL_EPSILON. Eachrho[j] * mmust also be (within tolerance) an integer.c—k × ksymmetric Bernoulli pref matrix on the micro-blocks, entries in[0, 1].p— Bernoulli rate for every edge crossing two distinct macro-blocks. Must lie in[0, 1].seed— initialises an internalSplitMix64PRNG.
The returned graph is always undirected, simple (no loops, no
multi-edges). Vertex ordering follows macro-block then micro-block:
macro b occupies the range [b*m, (b+1)*m), and inside it
micro-block j occupies [b*m + offset_j, b*m + offset_{j+1}).
§Errors
Returns IgraphError::InvalidArgument when any of the constraints
above is violated.
§Examples
use rust_igraph::hsbm_game;
// 2 macro-blocks of size 10, each with 2 micro-blocks of 5,
// strong within-cluster ties and a 1 % between-macro rate.
let rho = vec![0.5, 0.5];
let c = vec![vec![0.8, 0.05], vec![0.05, 0.8]];
let g = hsbm_game(20, 10, &rho, &c, 0.01, 42).unwrap();
assert_eq!(g.vcount(), 20);
assert!(!g.is_directed());