0
我有一個包含3000個節點的圖。我試圖使用pydot佈局引擎來尋找一個更愉快的佈局比默認networkx佈局layout = nx.fruchterman_reingold_layout(G)
如何使用graphviz通過networkx獲取圖形座標(佈局)?
的例子從neteorkx 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
有不止一次attibute 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