python-igraph icon indicating copy to clipboard operation
python-igraph copied to clipboard

Select and find should accept Vertex objects

Open kaymes opened this issue 9 years ago • 0 comments

The select and find functions of EdgeSeq should accept Vertex objects and interpret them correctly. Currently, it is necessary to use the vertex index explicitly to make it work.

To make things worse, the methods accept the Vertex object without error messages and simply don't return any edges. This is very error prone behaviour.

g=igraph.Graph(directed=True)
g.add_vertices(3)
g.add_edges([(0,1),(0,2),(2,0)])
vertex = g.vs[0]

g.es.select(_source=vertex.index)
g.es.select(_target=vertex.index)
g.es.find(_source=vertex.index)
g.es.find(_target=vertex.index)

g.es.select(_source=vertex)
g.es.select(_target=vertex)
g.es.find(_source=vertex)
g.es.find(_target=vertex)

The final four lines should return the same results as the middle four lines of code

kaymes avatar Feb 17 '16 22:02 kaymes