Skip to main content

symmetric_tree

Function symmetric_tree 

Source
pub fn symmetric_tree(branches: &[u32], mode: TreeMode) -> IgraphResult<Graph>
Expand description

Build a symmetric tree where each vertex at depth d has branches[d] children.

Vertex 0 is the root. Children at each level are added in BFS order, and the per-level branching count is read from branches. Empty branches yields the singleton tree on one vertex.

§Errors

§Examples

use rust_igraph::{symmetric_tree, TreeMode};

// Root + 2 kids + 4 grandkids = 7 vertices (perfect binary depth-2).
let t = symmetric_tree(&[2, 2], TreeMode::Undirected).unwrap();
assert_eq!(t.vcount(), 7);
assert_eq!(t.ecount(), 6);
assert!(!t.is_directed());