【发布时间】:2017-09-13 19:09:33
【问题描述】:
我有一个包含 3000 个节点的图表。我正在尝试使用 pydot 布局引擎来寻找比默认 networkx 布局更令人愉悦的布局layout = nx.fruchterman_reingold_layout(G)
来自networkx doc的例子
G_tst = nx.complete_graph(4)
pos = nx.nx_pydot.pydot_layout(G_tst )
pos = nx.nx_pydot.pydot_layout(G_tst , prog='dot')
工作得很好。但是,当我使用自己的图表时
pos = nx.nx_pydot.pydot_layout(G) 我得到一个Type Error,它声称G 不止一次拥有name 的属性。
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-72-1326868cc786> in <module>()
1
----> 2 pos = nx.nx_pydot.pydot_layout(G)
3 nx.draw(G, pos=pos)
C:\Anaconda3\lib\site-packages\networkx\drawing\nx_pydot.py in pydot_layout(G, prog, root, **kwds)
261 """
262 import pydotplus
--> 263 P=to_pydot(G)
264 if root is not None :
265 P.set("root",make_str(root))
C:\Anaconda3\lib\site-packages\networkx\drawing\nx_pydot.py in to_pydot(N, strict)
200 for n,nodedata in N.nodes_iter(data=True):
201 str_nodedata=dict((k,make_str(v)) for k,v in nodedata.items())
--> 202 p=pydotplus.Node(make_str(n),**str_nodedata)
203 P.add_node(p)
204
TypeError: __init__() got multiple values for argument 'name'
这是我有的node attributes:
`G.add_node(G.number_of_nodes(),
name=endNode.endWord, # string
teaching_text=endNode.tt_corpus, # string
definition=endNode.domainDef, # string
search_string=endNode.searchKey_obj.search_key_str,
name_len = len(endNode.endWord))` #int
【问题讨论】:
标签: python-3.x networkx graphviz pydot