[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] how to iterate a vertex seq to find neighbors
From: |
Tamas Nepusz |
Subject: |
Re: [igraph] how to iterate a vertex seq to find neighbors |
Date: |
Tue, 23 Dec 2008 19:06:11 +0100 |
btw, I see that get_eid(v1, v2) interprets v1 as the target node and
v2 as the source node in a directed graph... is it intentional?
well, in fact, get_eid(v1, v2) interprets v1 as the source and v2 as
the target. however, if the graph is directed and there is no v1 -->
v2 edge, igraph also tries v2 --> v1 UNLESS you add "directed=True":
In [7]: g=Graph([(0,1),(1,2),(2,1)], directed=True)
In [8]: g.get_eid(0,1)
Out[8]: 0
In [9]: g.get_eid(1,0)
Out[9]: 0
In [10]: g.get_eid(1,2)
Out[10]: 1
In [11]: g.get_eid(2,1)
Out[11]: 2
In [12]: g.get_eid(1,0,directed=True)
InternalError: Error at ../../src/type_indexededgelist.c:1055: Cannot
get edge id, no such edge, Invalid value
As you can see, g.get_eid(1,0) returns zero since there is no 1 --> 0
edge but there is a 0 --> 1 edge whose index is zero, but
g.get_eid(1,0,directed=True) throws an exception. This behaviour will
change in 0.6, however, and the default value for directed= will be
True as this is more logical.
--
Tamas