【问题标题】:igraph layout_reingold_tilford gives errorsigraph layout_reingold_tilford 给出错误
【发布时间】:2016-09-17 21:02:43
【问题描述】:

我在尝试使用 layout_reingold_tilford 布局时收到以下错误消息

文件“C:\Python27\lib\site-packages\igraph\layout.py”,第 80 行,在 init 中 self._coords = [list(coord) for coords in coords] TypeError: '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)

【问题讨论】:

  • 是的,使根可迭代工作。谢谢

标签: igraph


【解决方案1】:

看这个函数的C implementationroot被认为是可迭代only,但是documentation有点混乱:“根顶点或根的索引顶点”。

尝试改用root=[0]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-15
    • 1970-01-01
    相关资源
    最近更新 更多