ColorMap for Boost Graph Library "depth_first_search"

T

Tim Frink

Hi,

I want to use the depth_first_search algorithm from the Boost
Graph Library. However, I've problems with the definition of
my own ColorMap. To illustrate this, here is an example
(taken from http://www.boost.org/libs/graph/example/dfs-example.cpp):

int
main()
{
// Select the graph type we wish to use
typedef adjacency_list < vecS, vecS, directedS > graph_t;
typedef graph_traits < graph_t >::vertices_size_type size_type;

// Set up the vertex names
enum
{ u, v, w, x, y, z, N };
char name[] = { 'u', 'v', 'w', 'x', 'y', 'z' };

// Specify the edges in the graph
typedef std::pair < int, int >E;
E edge_array[] = { E(u, v), E(u, x), E(x, v), E(y, x),
E(v, y), E(w, y), E(w, z), E(z, z) };

graph_t g(edge_array, edge_array + sizeof(edge_array) / sizeof(E), N);

// Typedefs
typedef boost::graph_traits < graph_t >::vertex_descriptor Vertex;
typedef size_type* Iiter;

// discover time and finish time properties
std::vector < size_type > dtime(num_vertices(g));
std::vector < size_type > ftime(num_vertices(g));
size_type t = 0;
dfs_time_visitor < size_type * >vis(&dtime[0], &ftime[0], t);

// Some arbitrary vertex as root (start point of DFS)
Vertex root = source( edge_array[2],g );

depth_first_search(g, visitor(vis), myColorMap, root );

return 0;
}

My problem is the definition of "myColorMap" which must be
a model of Read/Write Property Map. However, I have no idea
how to define a working ColorMap. It would be fully sufficient
to take the default color map which is used when DFS is invoked
with "depth_first_search(g, visitor(vis));"

Do you have an idea how I define a ColorMap that I can use
for "myColorMap"?

Thank you.

Regards,
Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top