2 #include <boost/parameter.hpp>
4 BOOST_PARAMETER_NAME((_graph
, graphs
) graph
)
5 BOOST_PARAMETER_NAME((_visitor
, graphs
) visitor
)
6 BOOST_PARAMETER_NAME((_root_vertex
, graphs
) in(root_vertex
))
7 BOOST_PARAMETER_NAME((_index_map
, graphs
) in(index_map
))
8 BOOST_PARAMETER_NAME((_color_map
, graphs
) in_out(color_map
))
10 #include <boost/graph/graph_traits.hpp>
11 #include <boost/mpl/bool.hpp>
12 #include <boost/mpl/if.hpp>
13 #include <boost/type_traits/is_convertible.hpp>
14 #include <boost/type_traits/is_integral.hpp>
15 #include <boost/type_traits/is_same.hpp>
17 struct vertex_descriptor_predicate
19 template <typename T
, typename Args
>
22 boost::is_convertible
<
24 , typename
boost::graph_traits
<
25 typename
boost::parameter::value_type
<
38 #include <boost/mpl/eval_if.hpp>
40 struct graph_predicate
42 template <typename T
, typename Args
>
44 : boost::mpl::eval_if
<
45 boost::is_convertible
<
46 typename
boost::graph_traits
<T
>::traversal_category
47 , boost::incidence_graph_tag
50 boost::is_convertible
<
51 typename
boost::graph_traits
<T
>::traversal_category
52 , boost::vertex_list_graph_tag
63 #include <boost/property_map/property_map.hpp>
64 #include <boost/type_traits/is_same.hpp>
66 struct color_map_predicate
68 template <typename T
, typename Args
>
72 typename
boost::property_traits
<T
>::key_type
73 , typename
boost::graph_traits
<
74 typename
boost::parameter::value_type
<
87 #include <boost/type_traits/is_integral.hpp>
89 struct index_map_predicate
91 template <typename T
, typename Args
>
93 : boost::mpl::eval_if
<
95 typename
boost::property_traits
<T
>::value_type
99 typename
boost::property_traits
<T
>::key_type
100 , typename
boost::graph_traits
<
101 typename
boost::parameter::value_type
<
116 #include <boost/graph/properties.hpp>
119 template <typename Size
, typename IndexMap
>
120 boost::iterator_property_map
<
121 std::vector
<boost::default_color_type
>::iterator
123 , boost::default_color_type
124 , boost::default_color_type
&
126 default_color_map(Size num_vertices
, IndexMap
const& index_map
)
128 static std::vector
<boost::default_color_type
> colors(num_vertices
);
129 static boost::iterator_property_map
<
130 std::vector
<boost::default_color_type
>::iterator
132 , boost::default_color_type
133 , boost::default_color_type
&
134 > m(colors
.begin(), index_map
);
138 #include <boost/graph/depth_first_search.hpp>
140 BOOST_PARAMETER_FUNCTION((void), depth_first_search
, graphs
,
142 (graph
, *(graph_predicate
))
146 , * // not easily checkable
147 , boost::dfs_visitor
<>()
150 , *(vertex_descriptor_predicate
)
151 , *vertices(graph
).first
154 , *(index_map_predicate
)
155 , get(boost::vertex_index
, graph
)
158 , *(color_map_predicate
)
159 , default_color_map(num_vertices(graph
), index_map
)
166 #include <boost/core/lightweight_test.hpp>
167 #include <boost/graph/adjacency_list.hpp>
172 typedef boost::adjacency_list
<
177 enum {u
, v
, w
, x
, y
, z
, N
};
178 typedef std::pair
<std::size_t,std::size_t> E
;
180 E(u
, v
), E(u
, x
), E(x
, v
), E(y
, x
),
181 E(v
, y
), E(w
, y
), E(w
, z
), E(z
, z
)
183 G
g(edges
, edges
+ sizeof(edges
) / sizeof(E
), N
);
185 ::depth_first_search(g
);
186 ::depth_first_search(g
, _root_vertex
= static_cast<std::size_t>(x
));
187 return boost::report_errors();