retreiving parallel edges

11 views
Skip to first unread message

watson ix

unread,
Apr 11, 2014, 7:26:23 PM4/11/14
to pygraphvi...@googlegroups.com
hi there,

i have a separate (non-pygraphviz) program which returns the equivalent of 

import pygraphviz as GV
G = GV.AGraph(strict=False,directed=True)
G.add_edge('a','b',label='one')
G.add_edge('a','b',label='two')

and I want to be able to access both edges.

but when I do:
e = G.get_edge('a','b')
print e
print e.attr['label']

I get:
(u'a', u'b')
two

Is there any way to get access to both edges via reference to their nodes?

I can do:
print G.edges()

which gives:
[(u'a', u'b'), (u'a', u'b')]

but I'd rather not have to use a workaround of checking all edges in the graph!

w

Aric Hagberg

unread,
Apr 11, 2014, 8:53:24 PM4/11/14
to pygraphvi...@googlegroups.com
It would make sense for get_edge() to return both edges but I see that
isn't the case.
A workaround might be to pass the nodes to the edges() method.

In [25]: A = pgv.AGraph(strict=False)

In [26]: A.add_edge(1,2,key='one')

In [27]: A.add_edge(1,2,key='two')

In [28]: A.edges([1,2],keys=True)
Out[28]: [(u'1', u'2', u'one'), (u'1', u'2', u'two')]

Aric
> --
> You received this message because you are subscribed to the Google Groups
> "pygraphviz-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pygraphviz-disc...@googlegroups.com.
> To post to this group, send email to pygraphvi...@googlegroups.com.
> Visit this group at http://groups.google.com/group/pygraphviz-discuss.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages