pub fn tree_game_lerw(n: u32, directed: bool, seed: u64) -> IgraphResult<Graph>Expand description
Generate a uniformly random labelled tree on n vertices using
Wilson’s loop-erased random walk.
n— vertex count.n = 0returns an empty graph,n = 1returns a single isolated vertex.directed— iftrue, edges are stored with parent-to-child orientation in walk order (the resulting tree is rooted at the randomly chosen initial vertex). Iffalse, the same edges are stored as an undirected tree.seed— initialises an internalSplitMix64PRNG. Same(n, directed, seed)always yields the same tree.
The output has exactly max(0, n - 1) edges, is acyclic, has no
self-loops, and (in the undirected case) is connected.
§Examples
use rust_igraph::tree_game_lerw;
// 30-vertex undirected uniform random tree.
let g = tree_game_lerw(30, false, 0xC0FF_EE00).unwrap();
assert_eq!(g.vcount(), 30);
assert_eq!(g.ecount(), 29); // n - 1 edges
assert!(!g.is_directed());