Boost logo

Boost Users :

From: Matthias Linkenheil (M.Linkenheil_at_[hidden])
Date: 2005-01-05 11:26:12

Dear all,

i want to use the breadth_first_search algorithm to store the visited
nodes e.g. in a list for access in the main function.
Has anyone an idea to handle this?
In my code i print out the visited nodes.

The examples in the Boost User Guide about the visitor concept are
sometimes not so easy to understand.

using namespace boost;
template <typename VertexNameMap>
class bfs_name_printer:public default_bfs_visitor {
    bfs_name_printer(VertexNameMap n_map) : m_name_map(n_map){}
    template <typename Vertex, typename Graph>
        void discover_vertex(Vertex u, const Graph& ) const {
            std::cout<<get(m_name_map, u) <<" ";
    VertexNameMap m_name_map;



typedef property_map<Graph, vertex_index_t>::type VertexNameMap;
VertexNameMap id = get(vertex_index, g);
bfs_name_printer<VertexNameMap> vis(id);
breadth_first_search(fg, s, visitor(vis));



Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at