Create a k-ary tree graph, where almost all vertices other than the leaves have the same number of children.

make_tree(n, children = 2, mode = c("out", "in", "undirected"))

tree(...)

Arguments

n

Number of vertices.

children

Integer scalar, the number of children of a vertex (except for leafs)

mode

Defines the direction of the edges. out indicates that the edges point from the parent to the children, in indicates that they point from the children to their parents, while undirected creates an undirected graph.

...

Passed to make_tree() or sample_tree().

Value

An igraph graph

Examples

make_tree(10, 2)
#> IGRAPH 4172e4f D--- 10 9 -- Tree
#> + attr: name (g/c), children (g/n), mode (g/c)
#> + edges from 4172e4f:
#> [1] 1-> 2 1-> 3 2-> 4 2-> 5 3-> 6 3-> 7 4-> 8 4-> 9 5->10
make_tree(10, 3, mode = "undirected")
#> IGRAPH eff56a9 U--- 10 9 -- Tree
#> + attr: name (g/c), children (g/n), mode (g/c)
#> + edges from eff56a9:
#> [1] 1-- 2 1-- 3 1-- 4 2-- 5 2-- 6 2-- 7 3-- 8 3-- 9 3--10