Color map in forceth column widthth_first_visit

I want to use the boosts method breadth_first_visit, and I would like to provide it with my own “external” color map. I defined the schedule as follows:

typedef boost::adjacency_list<boost::setS, boost::listS, boost::undirectedS, 
  boost::property<boost::vertex_index_t, int, 
  boost::property<boost::vertex_color_t, boost::default_color_type, 
  Node_t>>>  GraphType;

where Node_tis the structure that defines the properties for the vertices. However, I cannot find out how I can provide BFS with my own color map. I would like to keep the colors of the vertices in the vector, so my definition looks like

std::vector<boost::default_color_type> colors;

but i cant figure out how to use this for bfs.

Neither

boost::breadth_first_search(g, *boost::vertices(g).first, 
  boost::color_map(colors));

and

boost::breadth_first_search(g, *boost::vertices(g).first, 
  boost::color_map(&colors[0]));

. (, default-int , "boost:: color_traits" ), C2664: "boost:: put" 2 'void *' 'ptrdiff_t'.

, : . : vertex_descriptor?

+5
1

, , . , , boost , :

, bfs, :

typedef boost::property_map<GraphType, boost::vertex_color_t>::type color_map_t;
color_map_t colorMap; //Create a color map

vertex_descriptor ( ) default_color_type. bfs

boost::breadth_first_visit(g, *boost::vertices(g).first, boost::color_map(colorMap));

color_names, ,

const char* color_names[] = {"white", "gray", "green", "red", "black"};

, vertex_descriptor [] - :

GraphType::vertex_iterator it, itEnd;
for (boost::tie(it, itEnd) = boost::vertices(g); it != itEnd; it++)
{
  std::cout << "Color of node " << *it << " is " << color_names[colorMap[*it]] << std::endl;
}
+4

All Articles