Here is maybe a code snippet demonstrating what I can't understand:

>>> j_e = eptm.graph.edge(4747, 2693)

>>> print('looking for: {}'.format(j_e))

looking for: (4747, 2693) 
>>> ## List of edges we're looking in:''')
>>> for e in eptm.cells.junctions[mother_cell]:
>>>    print(e)

(4747, 2693) (4747, 2692) (980, 2693) (4989, 980) (4989, 4990) (4990, 2692) 
>>> print('\n Is {} in the list? {}'.format(
>>>     j_e, j_e in eptm.cells.junctions[mother_cell]))

Is (4747, 2693) in the list? False

Here, eptm and eptm.cells are just container classes, and eptm.cells.junctions is a dictionary with the graphs vertices as keys.

Best,

Guillaume

Le 12/10/2014 01:57, Tiago de Paula Peixoto a écrit :

On 11.10.2014 17:11, Guillaume Gay wrote:
Hi all,

When manipulating a graph, I create a list of edges with a certain relation to a vertex (they are the edges common to the vertex‘s neighbour). I create this list at some moment in the code, and don’t update it.

Later down the execution, I try to remove one of those edges from the list prior to its deletion. That use to work without problem, until today (but I have ran the code since about a month ago).

Now when I try to |remove()| the edge, I get a ValueError because python tels me the edge is not in the list. When I look in the list, I see a reference to an edge with the correct source and target, but a different memory address, so I suspect that might be why it can be found…

Actually, when accessing an edge form a graph, the edge's address changes:

|
graph.edge(4747, 2693, all_edges=True)
[<Edge object with source '4747' and target '2693' at 0x7fd2d437c048>]

graph.edge(4747, 2693, all_edges=False)
<Edge object with source '4747' and target '2693' at 0x7fd2d437c0d8>

graph.edge(4747, 2693, all_edges=False)
<Edge object with source '4747' and target '2693' at 0x7fd2d437c168>|
This is entirely normal. Whenever Graph.edge() or Graph.vertex() is
called, a new edge or vertex descriptor instance is created. Many
different vertex or edge descriptors can point to the same edge or vertex,
i.e. they are not unique. The same thing happens for many other python
objects:

    >> a = 2.2
    >> id(a)
    140516113676112
    >> a = 2.2
    >> id(a)
    140516113676184

This should not be a problem, since vertex or edge descriptors which
point to the same vertex or edge should be considered equal, regardless
if they are distinct instances:

    >> g.edge(76, 62) == g.edge(76, 62)
    True

Note the latest digits of the address aren't the same. I see the same kind of things for the vertices, and it produces other bugs down the road (like this one when trying to add an edge between two vertices):

|TypeError: No registered converter was able to extract a C++ reference to type graph_tool::PythonVertex from this Python object of type NoneType|
I don't think this is related to the issue above.

Best,
Tiago



_______________________________________________
graph-tool mailing list
graph-tool@skewed.de
http://lists.skewed.de/mailman/listinfo/graph-tool