2013-08-16 32 views
5

graph.tree功能在包的igraph的docs劇情樹有與來自的igraph

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

輸出應表示數據作爲樹的例子。但我得到的是

enter image description here

回答

11

你顯然需要指定根:

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

tree

+0

許多THX你在哪裏得到這些信息? – Klaus

+0

這只是試驗和錯誤:我檢查了'?layout.reingold.tilford'並更改了參數,直到它工作。這可能是一個錯誤,因爲根的默認值應該是1. –

+0

我該如何做完整的二叉樹(每個頂點恰好有兩個孩子)? – CodeKingPlusPlus