pub fn regular_tree(h: u32, k: u32, mode: TreeMode) -> IgraphResult<Graph>Expand description
Build a regular tree (Bethe lattice) of height h and degree k.
Vertex 0 is the root and has k children; every internal non-root
vertex has k - 1 children plus its parent, giving total degree k.
Leaves sit at depth h.
§Errors
IgraphError::InvalidArgument—h < 1(height must be at least one; height zero would be a singleton, which is not a Bethe lattice — upstream rejects the same input).IgraphError::InvalidArgument—k < 2(degree must be at least two; degree one would mean every internal vertex has exactly one neighbour, which is degenerate).IgraphError::InvalidArgument— vertex count overflowsu32(propagated through the underlyingsymmetric_treecall).
§Examples
use rust_igraph::{regular_tree, TreeMode};
// h=2, k=3 — root has 3 kids, each internal has 2 kids: 1 + 3 + 6 = 10.
let t = regular_tree(2, 3, TreeMode::Undirected).unwrap();
assert_eq!(t.vcount(), 10);
assert_eq!(t.ecount(), 9);
assert!(!t.is_directed());