From: Boost-users [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Brian Davis via Boost-users Lets say I have a graph g (of type graph_t) and a color map (boy I wish I had a colormap):
There is not one single color_map class, it is a concept. Any object that has the following defined will do as a color map: Color c = get(my_color_map, vertex); // get the color of a vertex put(my_color_map, vertex, c); // set the color of a vertex my_color_map[vertex] = c; // get the color of a vertex (for an LValue property map) c = my_color_map[vertex]; // set the color of a vertex (for an LValue property map)
typedef boost::property_map
::type color_map_t; or is it?
That would only work if your graph type have a vertex_color property embedded in it, which is probably doesn't. If It did you could simply write auto colormap = boost::get(boost::vertex_color, g); The following that you propose look perfectly fine
auto indexmap = boost::get(boost::vertex_index, g); auto colors = boost::make_vector_property_mapboost::default_color_type(indexmap);
This looks good and would the preferred approach if you do not know the number of vertices when you construct the map, why did it not work?
If you do know the number of vertices, use shared_array_property_map instead.
Your code example is a bit garbled, but I think the problem is that you are constructing the filter with only two arguments (graph,vertex predicate), whereas the constructor expects (graph, edge predicate, vertex predicate) or (graph, edge predicate).
It is a pity that BGL does not have the enthusiastic support anymore that it used to have. Once you get used to it, it is very powerful.
The following compiles and runs correctly for me:
#include