In BGL, I can't quite figure out how to access the inherent colouring of the vertexes (white for untouched, grey for visited, black for finished) in a graph as they are visited during a bfs/dfs search.
Could somebody illustrate how to access a vertex' colour from within a dfs/bfs visitor? E.g. when writing a custom examine_edge?
You forgot to include a SSCCE, so I'll sketch a prose answer:
You should use the vertex color map.
This is a property_map. In case of internal property maps, you can access property maps using get:
Now you can query the map using
get:However, most often the colormap will be external, so you can just give the visitor access to it:
Direct Access To External Property Map
In this example I chose to make the colormap itself a property of the visitor. I didn't choose the most efficient representation (map) but it
listSinstead ofvecS)Live On Coliru
Prints
Using Internal Property
Live On Coliru
Prints
Shared Code