ColorMap for Boost Graph Library "depth_first_search"

Discussion in 'C++' started by Tim Frink, Feb 26, 2008.

  1. Tim Frink

    Tim Frink Guest

    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
     
    Tim Frink, Feb 26, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Isaac Gerg
    Replies:
    3
    Views:
    437
  2. George Sakkis
    Replies:
    1
    Views:
    468
    Szabolcs Nagy
    Jan 29, 2007
  3. Jef Driesen
    Replies:
    3
    Views:
    2,579
    mlimber
    Jan 24, 2006
  4. Almoni
    Replies:
    0
    Views:
    3,126
    Almoni
    Jan 17, 2010
  5. Emilio Mayorga
    Replies:
    6
    Views:
    364
    Martien Verbruggen
    Oct 8, 2003
Loading...

Share This Page