pub fn tree_game_prufer(n: u32, seed: u64) -> IgraphResult<Graph>Expand description
Generate a uniformly random labelled tree on n vertices using the
Prüfer sequence method.
Samples a random Prüfer sequence of length n - 2 (each entry
uniform in [0, n)), then decodes it with from_prufer to
produce an undirected labelled tree.
n— vertex count.n = 0returns an empty graph,n = 1returns a single isolated vertex.seed— initialises an internalSplitMix64PRNG. Same(n, seed)always yields the same tree.
The output has exactly max(0, n - 1) edges, is acyclic, has no
self-loops, and is connected.
Counterpart of the IGRAPH_RANDOM_TREE_PRUFER branch of
igraph_tree_game() in references/igraph/src/games/tree.c:37-56.
§Errors
IgraphError::InvalidArgument—noverflows internal allocation limits.
§Examples
use rust_igraph::tree_game_prufer;
let g = tree_game_prufer(30, 0xC0FF_EE00).unwrap();
assert_eq!(g.vcount(), 30);
assert_eq!(g.ecount(), 29);
assert!(!g.is_directed());