2

I have a graph with 3000 nodes. I am trying to use the pydot layout engine to find a more pleasing layout than the default networkx layout layout = nx.fruchterman_reingold_layout(G)

The example from 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')

works just fine. However when I use my own graph pos = nx.nx_pydot.pydot_layout(G) I get a Type Error where it claims that G has the attibute name more than once.

---------------------------------------------------------------------------
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'

Here are the node attributes I do have:

`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

1 Answer 1

4

I got the same error yesterday. I'm not 100 percent sure but it seems some internal variables conflict with your attribute "name". In my case, I change it to "name_" then it works.

Sign up to request clarification or add additional context in comments.

2 Comments

I got the same problem, which was solved by changing the name of the node attribute 'name'.
same happened to me: I had an attribute name defined within each node. Changed that to something else and solved the problem ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.