我有以下玩具图,例如,代表一个论坛主题:
import igraph as ig
g = ig.Graph(n = 12, directed=True)
g.add_edges([(1,0),(2,1), (3,2), (4,3),
(5,1),
(6,2), (7,6), (8,7),
(9,0),
(10,0), (11,10)])
g.vs["label"] = ["A", "B", "A", "B", "C", "F", "C", "B", "D", "C", "D", "F"]
ig.plot(g, layout="kk")
但是,似乎没有布局将根顶点(id 0,标签A)放置在顶部并向下生长.
我想念什么吗?
解决方法:
好的,我只是将其添加为评论的答案.
因此,Reingold-Tilford的布局有效:http://igraph.sourceforge.net/doc/python/igraph.Graph-class.html#layout_reingold_tilford
layout = g.layout_reingold_tilford(mode="in", root=0)