Check has edge for undirected graph
Question
I need to check if there is an edge between vertices in a undirected graph.
I tried this:
from igraph import *
g = Nexus.get("karate")
print "is directed: ", g.is_directed()
print "0,1: ", g.es.select(_from=0, _target=1)['weight']
print "1,0: ", g.es.select(_from=1, _target=0)['weight']
# Output
is directed: False
0,1: [4.0]
1,0: []
But, I want this result:
# Output
is directed: False
0,1: [4.0]
1,0: [4.0]
Solution
This is probably a bug in g.es.select
. Why not use g.es[g.get_eid(0, 1)]['weight']
instead? g.es.select
is slow anyway if you only need a single edge.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow