Klaus
Klaus

Reputation: 2056

Plot tree with graph.tree function from igraph

In the docs of igraph package there is an example

igraph.options(plot.layout=layout.reingold.tilford)
plot(graph.tree(20, 2))

the output should represent data as a tree. But what I get is

enter image description here

Upvotes: 5

Views: 11325

Answers (1)

Vincent Zoonekynd
Vincent Zoonekynd

Reputation: 32351

You apparently need to specify the root:

library(igraph)
g <- graph.tree(20, 2)
plot(g, layout = layout.reingold.tilford(g, root=1))

tree

Upvotes: 13

Related Questions