Skip to main content

regular_tree

Function regular_tree 

Source
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

§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());