pub fn kary_tree(n: u32, children: u32, mode: TreeMode) -> IgraphResult<Graph>Expand description
Build a k-ary tree on n vertices where each non-leaf parent has
up to children kids attached in BFS order.
For a perfectly symmetric tree of depth l use
n = (children^(l+1) - 1) / (children - 1).
See the module-level docs for the precise BFS layout and per-mode arc orientation.
§Errors
IgraphError::InvalidArgument—children == 0.
§Examples
use rust_igraph::{kary_tree, TreeMode};
// Binary tree with 7 vertices (perfect depth-2 tree).
let t = kary_tree(7, 2, TreeMode::Undirected).unwrap();
assert_eq!(t.vcount(), 7);
assert_eq!(t.ecount(), 6); // n - 1 edges
assert!(!t.is_directed());