Boost logo

Boost Users :

From: David E. Konerding (dekonerding_at_[hidden])
Date: 2006-02-27 14:33:53


Hi folks,

The bgl-python documentation says that the _graph.Graph.add_vertex()
function returns a Vertex object.

 From my testing, the Vertex object that gets returned doesn't actually
seem to be a member of the graph.
Is this intentional? I was hoping that the returned Vertex object was
valid, since I need access to it immediately.

Here's a test program. I woudl expect the values for v1 and v2 to be in
the graph, but they are not:

===================
import boost.graph as bgl

graph = bgl.Graph()
v1 = graph.add_vertex()
print "new v1=", v1
v2 = graph.add_vertex()
print "new v2=", v2
e = graph.add_edge(v1, v2)
print "new edge=", e
for vertex in graph.vertices:
    print "vertex: ", vertex
for edge in graph.edges:
    print "edge: ", edge

print "edge source:", graph.source(e)
=========================

Here's what I see:
new v1= <boost.graph._graph.Vertex object at 0x40168a04>
new v2= <boost.graph._graph.Vertex object at 0x40168aac>
new edge= <boost.graph._graph.Edge object at 0x40164dec>
vertex: <boost.graph._graph.Vertex object at 0x40168ae4>
vertex: <boost.graph._graph.Vertex object at 0x40168b54>
edge: <boost.graph._graph.Edge object at 0x40164d6c>
edge source: <boost.graph._graph.Vertex object at 0x40168ae4>

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.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net