I have this simple code in Python 3 using igraph to return an edge which I have added to an undirected graph.
from igraph import *
g = Graph()
g.add_vertices(3)
g.add_edges([(0,1), (1,2)])
# display(plot(g))
edge=g.es.find(_source=1, _target=0)
But when I use the function graph.es.find(), it gives me an error instead of returning the edge. It says that there is "no such edge".
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-14-4182287b1986> in <module>
4 g.add_edges([(0,1), (1,2)])
5 # display(plot(g))
----> 6 edge=g.es.find(_source=1, _target=0)
E:\Softwares\Anaconda\lib\site-packages\igraph\__init__.py in find(self, *args, **kwds)
3615 if es:
3616 return es[0]
-> 3617 raise ValueError("no such edge")
3618
3619 def select(self, *args, **kwds):
ValueError: no such edge
However it does return the edge if I set the source and destination in the same order as I entered them in. In this case, source = 0, target = 1
My guess is that it is not really an undirected graph.
And my question is, how do I get a truly undirected graph which returns the edge even if I switch the source and target nodes in the g.es.find() function, as it should be for an undirected graph?