2016-09-17 23 views
0

我在嘗試使用layout_reingold_tilford佈局的igraph layout_reingold_tilford給出錯誤

文件時出現以下錯誤消息 「C:\ Python27 \ LIB \站點包\ IGRAPH \ layout.py」,行80,在INIT self._coords = [列表(座標),用於在座標COORDS] 類型錯誤:

我已經發現以下問題,其具有一個簡單的問題和答案,但「INT」對象不是可迭代當我嘗試的例子我得到相同的錯誤

Plot a tree-like graph with root node at the top

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"] 
layout = g.layout_reingold_tilford(mode="in", root=0) 
ig.plot(g, layout=layout) 
+0

是的,使根迭代的作品。謝謝 –

回答

1

看着這個函數的C implementationroot被認爲是在迭代,然而documentation比較混亂:「根頂點或根頂點的索引」。

嘗試使用root=[0]代替。