Passing a string to agedge in agraph.py. Issue with networkx and pygraphviz Passing a string to agedge in agraph.py. Issue with networkx and pygraphviz python python

Passing a string to agedge in agraph.py. Issue with networkx and pygraphviz


Try changing the variable name from "key" to something else like "temp_key". I mean that it is possible that you (or any previously imported module) has declared a non-string type "key" variable before...?

Apparently if running :

eh = gv.agedge(self.handle, uh, vh, key , _Action.create)

fails but running:

eh = gv.agedge(self.handle, uh, vh, "key" , _Action.create)

give you no issue, it could only be relative to the "key" variable type.. did you try this:

eh = gv.agedge(self.handle, uh, vh, str(key) , _Action.create)

oreh = gv.agedge(self.handle, uh, vh, unicode(key) , _Action.create)

Integrate str()/unicode() in your orginal code give:

import networkx as nxG=nx.MultiGraph()fromnodes=[0,0,1,1,1,1,1,2,3,4,5,5,5,7,8,9,10]tonodes=[1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]dupedgeind=0for x,y in zip(fromnodes,tonodes):    if G.has_edge(x,y):        dupedgeind=dupedgeind+1        G.add_edge(x,y,key=str(dupedgeind))        #G.add_edge(x,y,key=unicode(dupedgeind))    else:        dupedgeind=0        G.add_edge(x,y,key=str(dupedgeind))        #G.add_edge(x,y,key=unicode(dupedgeind))

both (str & unicode version) works fine on Linux.

Best regards