ColorMap for Boost Graph Library "depth_first_search"

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim Frink

    ColorMap for Boost Graph Library "depth_first_search"

    Hi,

    I want to use the depth_first_sea rch 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/exam...-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_siz e_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_arr ay) / sizeof(E), N);

    // Typedefs
    typedef boost::graph_tr aits < graph_t >::vertex_descr iptor Vertex;
    typedef size_type* Iiter;

    // discover time and finish time properties
    std::vector < size_type dtime(num_verti ces(g));
    std::vector < size_type ftime(num_verti ces(g));
    size_type t = 0;
    dfs_time_visito r < 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_sea rch(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_se arch(g, visitor(vis));"

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

    Thank you.

    Regards,
    Tim

Working...