Python igraph无法在无向图中找到边

Python igraph无法在无向图中找到边,graph,igraph,python-3.7,undirected-graph,Graph,Igraph,Python 3.7,Undirected Graph,我在Python3中有一段简单的代码,使用igraph返回一条边,我已经将它添加到一个无向图中 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) 但是当我使用函数graph.es.find()时,它会给我一个错误,而不是返回边。它说“没有这样的优势” -------------

我在Python3中有一段简单的代码,使用igraph返回一条边,我已经将它添加到一个无向图中

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)
但是当我使用函数graph.es.find()时,它会给我一个错误,而不是返回边。它说“没有这样的优势”

---------------------------------------------------------------------------
ValueError回溯(最近一次调用上次)
在里面
4 g.添加_边([(0,1)、(1,2)])
5#显示(绘图(g))
---->6边=g.es.查找(_源=1,_目标=0)
E:\Softwares\Anaconda\lib\site packages\igraph\\uuuuu init\uuuuuuuu.py in find(self,*args,**kwds)
3615如果是:
3616返回es[0]
->3617提升值错误(“无此边缘”)
3618
3619 def选择(自身,*args,**kwds):
ValueError:没有这样的边缘
但是,如果我按照输入源和目标的相同顺序设置它们,它会返回边缘。在这种情况下,源=0,目标=1
我的猜测是,它不是一个真正的无向图


我的问题是,即使我在g.es.find()函数中切换了源节点和目标节点,如何得到一个真正的无向图,它也会返回边,就像无向图应该的那样?

使用此方法获得边:

from igraph import *
g = Graph()
g.add_vertices(3)
g.add_edges([(0,1), (1,2)])

#get the ID
g.get_eid(0,1)
0

#get the edge list
g.get_edgelist()
[(0, 1), (1, 2)]

#get the first edge from the edge list
g.get_edgelist()[0]
(0, 1)

最后,要验证它不是定向的,请使用
g.is_directed()

为什么会发生这种情况?你不认为这是违反直觉的吗?不。文档中介绍了这些方法以获得边缘。你使用的函数我以前从未在这里见过。此函数完成其他工作<代码>g.es.查找(权重_gt=5)这将查找指定权重大于5的边。看医生。考虑接受和支持我的回答
from igraph import *
g = Graph()
g.add_vertices(3)
g.add_edges([(0,1), (1,2)])

#get the ID
g.get_eid(0,1)
0

#get the edge list
g.get_edgelist()
[(0, 1), (1, 2)]

#get the first edge from the edge list
g.get_edgelist()[0]
(0, 1)