Hi, This is a bug in the Python interface; _source and _target do not work properly on undirected graphs. As a workaround, use g.incident(x) to obtain the IDs of the edges incident on vertex x -- this can then be used to subset g.es:
g.es[g.incident(x)] Please file a bug report on https://github.com/igraph/python-igraph/issues/new if you want to track the progress of this issue. -- T. On 05/06, Santiago Videla wrote: > Hi, > > > Using igraph-python, I found something which as far as I understand, it > doesn't match the documentation: > > > In [1]: import igraph as ig > > In [2]: g = ig.Graph(3, [(0,1), (2,0)], directed=False) > > In [3]: len(g.es.select(_source=0)) > > Out[3]: 2 > > In [4]: len(g.es.select(_target=0)) > > Out[4]: 0 > > Shouldn't g.es.select(_target=0) return 2 edges as well? > > In fact, in the tutorial ( > http://igraph.org/python/doc/tutorial/tutorial.html#querying-vertices-and-edges-based-on-attributes) > it says: > > ============= > There are also a few special structural properties for selecting edges: > > Using _source or _from in the keyword argument list of EdgeSeq.select() > filters based on the source vertices of the edges. E.g., to select all the > edges originating from Claire (who has vertex index 2): > > >>> g.es.select(_source=2) > > Using _target or _to filters based on the target vertices. This is > different from _source and _from if the graph is directed. > ============= > > I understand that for an undirected graph, it should hold:: > > g.es.select(_source=vid) == g.es.select(_target=vid) > > or not? > > Regards, > > -- > Santiago Videla > http://www.linkedin.com/in/svidela > _______________________________________________ > igraph-help mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/igraph-help -- T. _______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
