&, ColorMap color) { depth_first_search(g, vis, color, start_vertex); } }; template <> struct dfs_dispatch { template static void apply(const VertexListGraph& g, DFSVisitor vis, Vertex start_vertex, const bgl_named_params& params, detail::error_property_not_found) { std::vector color_vec(num_vertices(g)); default_color_type c = white_color; // avoid warning about un-init depth_first_search (g, vis, make_iterator_property_map (color_vec.begin(), choose_const_pmap(get_param(params, vertex_index), g, vertex_index), c), start_vertex); } }; } // namespace detail template class dfs_visitor { public: dfs_visitor() { } dfs_visitor(Visitors vis) : m_vis(vis) { } template void initialize_vertex(Vertex u, const Graph& g) { invoke_visitors(m_vis, u, g, ::boost::on_initialize_vertex()); } template void start_vertex(Vertex u, const Graph& g) { invoke_visitors(m_vis, u, g, ::boost::on_start_vertex()); } template void discover_vertex(Vertex u, const Graph& g) { invoke_visitors(m_vis, u, g, ::boost::on_discover_vertex()); } template void examine_edge(Edge u, const Graph& g) { invoke_visitors(m_vis, u, g, ::boost::on_examine_edge()); } template void tree_edge(Edge u, const Graph& g) { invoke_visitors(m_vis, u, g, ::boost::on_tree_edge()); } template void back_edge(Edge u, const Graph& g) { invoke_visitors(m_vis, u, g, ::boost::on_back_edge()); } template void forward_or_cross_edge(Edge u, const Graph& g) { invoke_visitors(m_vis, u, g, ::boost::on_forward_or_cross_edge()); } template void finish_vertex(Vertex u, const Graph& g) { invoke_visitors(m_vis, u, g, ::boost::on_finish_vertex()); } BOOST_GRAPH_EVENT_STUB(on_initialize_vertex,dfs) BOOST_GRAPH_EVENT_STUB(on_start_vertex,dfs) BOOST_GRAPH_EVENT_STUB(on_discover_vertex,dfs) BOOST_GRAPH_EVENT_STUB(on_examine_edge,dfs) BOOST_GRAPH_EVENT_STUB(on_tree_edge,dfs) BOOST_GRAPH_EVENT_STUB(on_back_edge,dfs) BOOST_GRAPH_EVENT_STUB(on_forward_or_cross_edge,dfs) BOOST_GRAPH_EVENT_STUB(on_finish_vertex,dfs) protected: Visitors m_vis; }; template dfs_visitor make_dfs_visitor(Visitors vis) { return dfs_visitor(vis); } typedef dfs_visitor<> default_dfs_visitor; // Named Parameter Variant template void depth_first_search(const VertexListGraph& g, const bgl_named_params& params) { typedef typename property_value< bgl_named_params, vertex_color_t>::type C; if (vertices(g).first == vertices(g).second) return; detail::dfs_dispatch::apply (g, choose_param(get_param(params, graph_visitor), make_dfs_visitor(null_visitor())), choose_param(get_param(params, root_vertex_t()), *vertices(g).first), params, get_param(params, vertex_color) ); } template void depth_first_visit (const IncidenceGraph& g, typename graph_traits::vertex_descriptor u, DFSVisitor vis, ColorMap color) { vis.start_vertex(u, g); detail::depth_first_visit_impl(g, u, vis, color, detail::nontruth2()); } template void depth_first_visit (const IncidenceGraph& g, typename graph_traits::vertex_descriptor u, DFSVisitor vis, ColorMap color, TerminatorFunc func = TerminatorFunc()) { vis.start_vertex(u, g); detail::depth_first_visit_impl(g, u, vis, color, func); } } // namespace boost #endif
& params, detail::error_property_not_found) { std::vector color_vec(num_vertices(g)); default_color_type c = white_color; // avoid warning about un-init depth_first_search (g, vis, make_iterator_property_map (color_vec.begin(), choose_const_pmap(get_param(params, vertex_index), g, vertex_index), c), start_vertex); } }; } // namespace detail template class dfs_visitor { public: dfs_visitor() { } dfs_visitor(Visitors vis) : m_vis(vis) { } template void initialize_vertex(Vertex u, const Graph& g) { invoke_visitors(m_vis, u, g, ::boost::on_initialize_vertex()); } template void start_vertex(Vertex u, const Graph& g) { invoke_visitors(m_vis, u, g, ::boost::on_start_vertex()); } template void discover_vertex(Vertex u, const Graph& g) { invoke_visitors(m_vis, u, g, ::boost::on_discover_vertex()); } template void examine_edge(Edge u, const Graph& g) { invoke_visitors(m_vis, u, g, ::boost::on_examine_edge()); } template void tree_edge(Edge u, const Graph& g) { invoke_visitors(m_vis, u, g, ::boost::on_tree_edge()); } template void back_edge(Edge u, const Graph& g) { invoke_visitors(m_vis, u, g, ::boost::on_back_edge()); } template void forward_or_cross_edge(Edge u, const Graph& g) { invoke_visitors(m_vis, u, g, ::boost::on_forward_or_cross_edge()); } template void finish_vertex(Vertex u, const Graph& g) { invoke_visitors(m_vis, u, g, ::boost::on_finish_vertex()); } BOOST_GRAPH_EVENT_STUB(on_initialize_vertex,dfs) BOOST_GRAPH_EVENT_STUB(on_start_vertex,dfs) BOOST_GRAPH_EVENT_STUB(on_discover_vertex,dfs) BOOST_GRAPH_EVENT_STUB(on_examine_edge,dfs) BOOST_GRAPH_EVENT_STUB(on_tree_edge,dfs) BOOST_GRAPH_EVENT_STUB(on_back_edge,dfs) BOOST_GRAPH_EVENT_STUB(on_forward_or_cross_edge,dfs) BOOST_GRAPH_EVENT_STUB(on_finish_vertex,dfs) protected: Visitors m_vis; }; template dfs_visitor make_dfs_visitor(Visitors vis) { return dfs_visitor(vis); } typedef dfs_visitor<> default_dfs_visitor; // Named Parameter Variant template void depth_first_search(const VertexListGraph& g, const bgl_named_params& params) { typedef typename property_value< bgl_named_params, vertex_color_t>::type C; if (vertices(g).first == vertices(g).second) return; detail::dfs_dispatch::apply (g, choose_param(get_param(params, graph_visitor), make_dfs_visitor(null_visitor())), choose_param(get_param(params, root_vertex_t()), *vertices(g).first), params, get_param(params, vertex_color) ); } template void depth_first_visit (const IncidenceGraph& g, typename graph_traits::vertex_descriptor u, DFSVisitor vis, ColorMap color) { vis.start_vertex(u, g); detail::depth_first_visit_impl(g, u, vis, color, detail::nontruth2()); } template void depth_first_visit (const IncidenceGraph& g, typename graph_traits::vertex_descriptor u, DFSVisitor vis, ColorMap color, TerminatorFunc func = TerminatorFunc()) { vis.start_vertex(u, g); detail::depth_first_visit_impl(g, u, vis, color, func); } } // namespace boost #endif
& params) { typedef typename property_value< bgl_named_params
, vertex_color_t>::type C; if (vertices(g).first == vertices(g).second) return; detail::dfs_dispatch::apply (g, choose_param(get_param(params, graph_visitor), make_dfs_visitor(null_visitor())), choose_param(get_param(params, root_vertex_t()), *vertices(g).first), params, get_param(params, vertex_color) ); } template void depth_first_visit (const IncidenceGraph& g, typename graph_traits::vertex_descriptor u, DFSVisitor vis, ColorMap color) { vis.start_vertex(u, g); detail::depth_first_visit_impl(g, u, vis, color, detail::nontruth2()); } template void depth_first_visit (const IncidenceGraph& g, typename graph_traits::vertex_descriptor u, DFSVisitor vis, ColorMap color, TerminatorFunc func = TerminatorFunc()) { vis.start_vertex(u, g); detail::depth_first_visit_impl(g, u, vis, color, func); } } // namespace boost #endif