使用igraph的graph.tree函数绘制树 [英] Plot tree with graph.tree function from igraph
本文介绍了使用igraph的graph.tree函数绘制树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在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
推荐答案
您显然需要指定根目录:
You apparently need to specify the root:
library(igraph)
g <- graph.tree(20, 2)
plot(g, layout = layout.reingold.tilford(g, root=1))
这篇关于使用igraph的graph.tree函数绘制树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文