views:

17

answers:

0

I use Boost Graph Library in a project and it is declared as:

typedef adjacency_list <listS, listS, undirectedS, TrackInformation, LinkInformation> TracksConnectionGraph;

Things are going fine until I have to call connected_components on my graph.

typedef std::map<TracksConnectionGraph::vertex_descriptor, TracksConnectionGraph::vertices_size_type> component_type;
component_type component;
boost::associative_property_map< component_type > component_map(component);

int num_components = connected_components(tracks_connection_graph_, component_map);

The problem seems to be that if the VertexList=listS, I do not have vertex_index as a property of my vertex. This makes connected_components give me errors like theses:

/usr/local/include/boost-1_39/boost/property_map.hpp: In member function 'R boost::iterator_property_map::operator[](typename boost::property_traits::key_type) const [with RandomAccessIterator = __gnu_cxx::__normal_iterator , IndexMap = boost::adj_list_vertex_property_map, boost::detail::error_property_not_found, const boost::detail::error_property_not_found&, boost::vertex_index_t>, T = boost::default_color_type, R = boost::default_color_type&]':

So the question is: how do I add vertex_index as a property of my vertices?

If I add it, does it mean that whenever I call add_vertex, remove_vertex and such, I have to update this information for each vertex?