[Boost.Graph] graph.vertices property creates new objects
George Sakkis
george.sakkis at gmail.com
Mon Jan 29 13:36:38 EST 2007
I've just started toying with the python bindings of BGL and I'm
puzzled from the following:
>>> from boost.graph import Graph
>>> g = Graph()
>>> v = g.add_vertex()
>>> g.vertices.next() == v
True
>>> g.vertices.next() is v
False
It seems that the vertices iterator creates new vertex objects every
time instead of iterating over the existing ones. This essentially
prevents, among other things, storing vertices as keys in a dictionary
since the hashes of the stored and the new vertex differ although they
compare equal. Is this really what's happening, and if so, why ?
George
More information about the Python-list
mailing list