Create a k-ary tree graph, where almost all vertices other than the leaves have the same number of children.
Usage
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)
- ...
Passed to
make_tree()orsample_tree().- mode
Defines the direction of the edges.
outindicates that the edges point from the parent to the children,inindicates that they point from the children to their parents, whileundirectedcreates an undirected graph.
See also
Other deterministic constructors:
graph_from_atlas(),
graph_from_edgelist(),
graph_from_literal(),
make_(),
make_chordal_ring(),
make_circulant(),
make_empty_graph(),
make_full_citation_graph(),
make_full_graph(),
make_full_multipartite(),
make_graph(),
make_lattice(),
make_ring(),
make_star(),
make_turan(),
make_wheel()
Examples
make_tree(10, 2)
#> ── <igraph> Tree ──────────────────────────────────────────────────── 0e5ffaf ──
#> ℹ directed
#> ℹ 10 vertices · 9 edges
#>
#> ── Attributes ──────────────────────────────────────────────────────────────────
#> → graph: name <chr>, children <dbl>, mode <chr>
#>
#> ── Edges ───────────────────────────────────────────────────────────────────────
#> [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> Tree ──────────────────────────────────────────────────── 75f886f ──
#> ℹ undirected
#> ℹ 10 vertices · 9 edges
#>
#> ── Attributes ──────────────────────────────────────────────────────────────────
#> → graph: name <chr>, children <dbl>, mode <chr>
#>
#> ── Edges ───────────────────────────────────────────────────────────────────────
#> [1] 1 ─ 2 1 ─ 3 1 ─ 4 2 ─ 5 2 ─ 6 2 ─ 7 3 ─ 8 3 ─ 9 3 ─ 10
