pub fn hrg_sample(hrg: &HrgTree, seed: u64) -> IgraphResult<Graph>Expand description
Sample a random graph from a hierarchical random graph model.
For each pair of leaf vertices (i, j), an undirected edge is added
with probability equal to the connection probability at their lowest
common ancestor in the dendrogram.
seed initialises the internal PRNG. Same (hrg, seed) always
produces the same graph.
ยงExample
use rust_igraph::{HrgTree, hrg_sample};
let mut hrg = HrgTree::new(4);
hrg.left[0] = -2; hrg.right[0] = -3; hrg.prob[0] = 0.5;
hrg.left[1] = 0; hrg.right[1] = 1; hrg.prob[1] = 1.0;
hrg.left[2] = 2; hrg.right[2] = 3; hrg.prob[2] = 1.0;
hrg.vertices = vec![4, 2, 2];
hrg.edges = vec![6, 2, 2];
let g = hrg_sample(&hrg, 42).unwrap();
assert_eq!(g.vcount(), 4);
// With prob=1.0 within subtrees, leaves 0-1 and 2-3 are always connected