Doug Gregor wrote:
As you can see, v1 and v2 return and have different addresses than the Vertex objects that are listed by the vertices iterator. My guess here is that the Vertex objects do point to the same underlying vertex in the C++ implementation of the graph.
Your guess is correct. We don't cache the Python objects corresponding to vertex and edge descriptors.
Ah. OK. Well, I guess that leads me to my next question. I am writing a model-view graph editor using bgl-python (which the model implemented as a boost graph). Originally my idea was to keep the mapping between on-screen widgets and the graph vertices they corresponded to in a dictionary: self._widgetmap[vertex] = widget However, since Vertex objects aren't cached, placing the vertex object I get back from add_vertex obviously isn't going to work. I got to thinking, and it seems to me like the 'right way' to do this would be to invert the problem (somewhat violating the model/view abstraction): add a vertex property map to the graph with mappings from the graph vertex object to the widget. I can't see another way to do it if Vertex objects aren't cached. Dave