[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] n-ary trees
From: |
Tamás Nepusz |
Subject: |
Re: [igraph] n-ary trees |
Date: |
Sun, 22 Jan 2012 01:09:31 +0100 |
> Is there a function to generate n-ary trees? graph.tree with children=n does
> not seem to do the job.
It depends on how you define n-ary trees ;) In igraph, graph.tree generates
trees where each node has at most n children. If the tree is undirected, then
it means that the root has degree n, branching nodes have degree n+1 (except
the root of course) and leaves have degree 1. If you need a tree where the root
and the branches both have degree n, you can use graph.tree with children=n-1
and attach another graph.tree with children=n-1 to the root. You must make sure
that the second graph has one less layers than the first. E.g.:
g <- graph.tree(n=13, children=3, directed=F) + graph.tree(n=4, children=3,
directed=F)
g <- add.edges(g, c(0, 13))
Cheers,
Tamas