igraph layout_reingold_tilford gives errors

拈花ヽ惹草 提交于 2019-12-12 03:42:57

问题


I get the following error message when trying to use the layout_reingold_tilford layout

File "C:\Python27\lib\site-packages\igraph\layout.py", line 80, in init self._coords = [list(coord) for coord in coords] TypeError: 'int' object is not iterable

I have found the following question which has a simple question and answer but when I try the example I get the same error

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)

回答1:


Looking at the C implementation of this function, root is considered to be in iterable only, however the documentation is a bit confusing: "the index of the root vertex or root vertices".

Try to use root=[0] instead.



来源:https://stackoverflow.com/questions/39551715/igraph-layout-reingold-tilford-gives-errors

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!