Graphviz Issue Tracker - graphviz
View Issue Details
0002591graphvizGVeditpublic2016-03-02 07:582016-03-02 08:29
LT 
 
normalimportantalways
newopen 
Windows7Enterprise SP1
2.38
0002591: Interface with pygraphviz - possible issue with Agedge_t *agedge(...) in edge.c
Dear all,

Many thanks for producing and maintaining such useful software.

This problem is documented here: http://stackoverflow.com/questions/35610736/passing-a-string-to-agedge-in-agraph-py-issue-with-networkx-and-pygraphviz [^]

My issue relates to interactrion with pygraphviz - a python/SWIG wrapper for graphviz.

When this calls the following function, nothing is return resulting in an error:

Agedge_t *agedge(Agraph_t * g, Agnode_t * t, Agnode_t * h, char *name,
int cflag)

I'm really not convinced that this is an issue with graphviz itself, but I've raised this here just in case it is.

In python console with Graphviz2.38, networkx 1.11 and pygraphviz installed from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygraphviz: [^]


import networkx as nx
G=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=0
for x,y in zip(fromnodes,tonodes):
    if G.has_edge(x,y):
        dupedgeind=dupedgeind+1
        G.add_edge(x,y,key=dupedgeind)
    else:
        dupedgeind=0
        G.add_edge(x,y,key=dupedgeind)

pos=nx.nx_agraph.pygraphviz_layout(G,prog='sfdp')

Produces the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\networkx\drawing\nx_agraph.py", line 262, in pygraphviz_layout
    A=to_agraph(G)
  File "C:\Python27\lib\site-packages\networkx\drawing\nx_agraph.py", line 155, in to_agraph
    A.add_edge(u,v,key=str(key),**str_edgedata)
  File "C:\Python27\lib\site-packages\pygraphviz\agraph.py", line 484, in add_edge
    eh = gv.agedge(self.handle, uh, vh, key, _Action.find)
KeyError: 'agedge: no key'
This problem is documented here: http://stackoverflow.com/questions/35610736/passing-a-string-to-agedge-in-agraph-py-issue-with-networkx-and-pygraphviz [^]


I think the source of the error is within this pygraphviz file, graphviz_wrap.c, line 3921:

https://github.com/pygraphviz/pygraphviz/blob/245fc9507a9e40f8c35762dd5073e42edb0388d3/pygraphviz/graphviz_wrap.c [^]

I've also raised reports on the networkx and pygraphviz source repositories:

https://github.com/networkx/networkx/issues/2012 [^]
https://github.com/pygraphviz/pygraphviz/issues/88 [^]
No tags attached.
Issue History
2016-03-02 07:58LTNew Issue
2016-03-02 08:29LTNote Added: 0001037

Notes
(0001037)
LT   
2016-03-02 08:29   
Apologies, GVedit category is incorrect. Should be Other.