2008-09-16

The Boost graph with VertexList=listS has NO built-in vertex_index property

This is the answer from the author of BGL.

----

Hi Christoph,

The problem with your example is that you forgot to initialize the
vertex_index property for each vertex. Perhaps you thought that the
adjacency_list would do this for you. However, this is not the case when
using VertexList=listS. I know this is confusing, but it is stated in the
docs that there is a builtin vertex_index property when VertexList=vecS,
whereas you were using listS.

So you need to add a couple calls to "put" to fix the situation.

u = boost::add_vertex( g );
put(boost::vertex_index, g, u, 0);
v = boost::add_vertex( g );
put(boost::vertex_index, g, v, 1);

沒有留言:

張貼留言