diff --git a/doc/astar_search.html b/doc/astar_search.html
index 89f61e04..22b17d7d 100644
--- a/doc/astar_search.html
+++ b/doc/astar_search.html
@@ -22,7 +22,7 @@
-// Named parameter interface
+// Named parameter interfaces
template <typename VertexListGraph,
typename AStarHeuristic,
typename P, typename T, typename R>
@@ -32,6 +32,15 @@ astar_search
typename graph_traits<VertexListGraph>::vertex_descriptor s,
AStarHeuristic h, const bgl_named_params<P, T, R>& params);
+template <typename VertexListGraph,
+ typename AStarHeuristic,
+ typename P, typename T, typename R>
+void
+astar_search_no_init
+ (const VertexListGraph &g,
+ typename graph_traits<VertexListGraph>::vertex_descriptor s,
+ AStarHeuristic h, const bgl_named_params<P, T, R>& params);
+
// Non-named parameter interface
template <typename VertexListGraph, typename AStarHeuristic,
typename AStarVisitor, typename PredecessorMap,
@@ -71,7 +80,8 @@ astar_search_no_init
CostInf inf, CostZero zero);
Note that the index_map and color parameters are swapped in
-astar_search_no_init relative to astar_search.
+astar_search_no_init() relative to astar_search(); the named parameter
+interfaces are not affected.
@@ -110,7 +120,7 @@ A* is particularly useful for searching implicit graphs.
Implicit graphs are graphs that are not completely known at the
beginning of the search. Upon visiting a vertex, its neighbors are
"generated" and added to the search. Implicit graphs are particularly
-useful for searching large state spaces -- in gameplaying scenarios
+useful for searching large state spaces -- in game-playing scenarios
(e.g. chess), for example -- in which it may not be possible to store
the entire graph. Implicit searches can be performed with this
implementation of A* by creating special visitors that generate
@@ -293,7 +303,7 @@ IN: vertex_index_map(VertexIndexMap i_map)
Default: get(vertex_index, g).
Note: if you use this default, make sure your graph has
an internal vertex_index property. For example,
- adjacenty_list with VertexList=listS does
+ adjacency_list with VertexList=listS does
not have an internal vertex_index property.
@@ -330,8 +340,8 @@ UTIL/OUT: distance_map(DistanceMap d_map)
href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">StrictWeakOrdering
provided by the compare function object.
- Default: iterator_property_map created from a
- std::vector with the same value type as the
+ Default: shared_array_property_map
+ with the same value type as the
WeightMap, and of size num_vertices(g), and using
the i_map for the index map.
@@ -356,9 +366,9 @@ UTIL/OUT: rank_map(CostMap c_map)
for this map must be the same as the value type for the distance
map.
- Default: iterator_property_map created from a
- std::vector with the same value type as the
- WeightMap, and of size num_vertices(g), and using
+ Default: shared_array_property_map
+ with the same value type as the
+ DistanceMap, and of size num_vertices(g), and using
the i_map for the index map.
@@ -378,10 +388,10 @@ UTIL/OUT: color_map(ColorMap c_map)
key type of the map, and the value type of the map must be a model
of Color Value.
- Default: iterator_property_map created from a
- std::vector of value type default_color_type, with
- size num_vertices(g), and using the i_map for the
- index map.
+ Default: shared_array_property_map
+ of value type default_color_type, with size
+ num_vertices(g), and using
+ the i_map for the index map.
IN: distance_compare(CompareFunction cmp)
diff --git a/include/boost/graph/astar_search.hpp b/include/boost/graph/astar_search.hpp
index cd312f2e..576ac56a 100644
--- a/include/boost/graph/astar_search.hpp
+++ b/include/boost/graph/astar_search.hpp
@@ -300,63 +300,7 @@ namespace boost {
}
-
-
- namespace detail {
- template
- inline void
- astar_dispatch2
- (const VertexListGraph& g,
- typename graph_traits::vertex_descriptor s,
- AStarHeuristic h, CostMap cost, DistanceMap distance,
- WeightMap weight, IndexMap index_map, ColorMap color,
- const Params& params)
- {
- dummy_property_map p_map;
- typedef typename property_traits::value_type C;
- astar_search
- (g, s, h,
- choose_param(get_param(params, graph_visitor),
- make_astar_visitor(null_visitor())),
- choose_param(get_param(params, vertex_predecessor), p_map),
- cost, distance, weight, index_map, color,
- choose_param(get_param(params, distance_compare_t()),
- std::less()),
- choose_param(get_param(params, distance_combine_t()),
- closed_plus()),
- choose_param(get_param(params, distance_inf_t()),
- std::numeric_limits::max BOOST_PREVENT_MACRO_SUBSTITUTION ()),
- choose_param(get_param(params, distance_zero_t()),
- C()));
- }
-
- template
- inline void
- astar_dispatch1
- (const VertexListGraph& g,
- typename graph_traits::vertex_descriptor s,
- AStarHeuristic h, CostMap cost, DistanceMap distance,
- WeightMap weight, IndexMap index_map, ColorMap color,
- const Params& params)
- {
- typedef typename property_traits::value_type D;
-
- detail::astar_dispatch2
- (g, s, h,
- choose_param(cost, vector_property_map(index_map)),
- choose_param(distance, vector_property_map(index_map)),
- weight, index_map,
- choose_param(color, vector_property_map(index_map)),
- params);
- }
- } // namespace detail
-
-
- // Named parameter interface
+ // Named parameter interfaces
template
@@ -366,16 +310,67 @@ namespace boost {
typename graph_traits::vertex_descriptor s,
AStarHeuristic h, const bgl_named_params& params)
{
+ using namespace boost::graph::keywords;
+ typedef bgl_named_params
params_type;
+ BOOST_GRAPH_DECLARE_CONVERTED_PARAMETERS(params_type, params)
- detail::astar_dispatch1
+ // Distance type is the value type of the distance map if there is one,
+ // otherwise the value type of the weight map.
+ typedef
+ typename detail::override_const_property_result<
+ arg_pack_type, tag::weight_map, edge_weight_t, VertexListGraph>::type
+ weight_map_type;
+ typedef typename boost::property_traits::value_type W;
+ typedef
+ typename detail::map_maker::map_type
+ distance_map_type;
+ typedef typename boost::property_traits::value_type D;
+
+ astar_search
(g, s, h,
- get_param(params, vertex_rank),
- get_param(params, vertex_distance),
- choose_const_pmap(get_param(params, edge_weight), g, edge_weight),
- choose_const_pmap(get_param(params, vertex_index), g, vertex_index),
- get_param(params, vertex_color),
- params);
+ arg_pack[_visitor | make_astar_visitor(null_visitor())],
+ arg_pack[_predecessor_map | dummy_property_map()],
+ detail::make_property_map_from_arg_pack_gen(D())(g, arg_pack),
+ detail::make_property_map_from_arg_pack_gen(W())(g, arg_pack),
+ override_const_property(arg_pack, _weight_map, g, edge_weight),
+ override_const_property(arg_pack, _vertex_index_map, g, vertex_index),
+ detail::make_color_map_from_arg_pack(g, arg_pack),
+ arg_pack[_distance_compare | std::less()],
+ arg_pack[_distance_combine | closed_plus()],
+ arg_pack[_distance_inf | (std::numeric_limits::max)()],
+ arg_pack[_distance_zero | D()]);
+ }
+ template
+ void
+ astar_search_no_init
+ (const VertexListGraph &g,
+ typename graph_traits::vertex_descriptor s,
+ AStarHeuristic h, const bgl_named_params& params)
+ {
+ using namespace boost::graph::keywords;
+ typedef bgl_named_params
params_type;
+ BOOST_GRAPH_DECLARE_CONVERTED_PARAMETERS(params_type, params)
+ typedef
+ typename detail::override_const_property_result<
+ arg_pack_type, tag::weight_map, edge_weight_t, VertexListGraph>::type
+ weight_map_type;
+ typedef typename boost::property_traits::value_type D;
+ astar_search_no_init
+ (g, s, h,
+ arg_pack[_visitor | make_astar_visitor(null_visitor())],
+ arg_pack[_predecessor_map | dummy_property_map()],
+ detail::make_property_map_from_arg_pack_gen(D())(g, arg_pack),
+ detail::make_property_map_from_arg_pack_gen(D())(g, arg_pack),
+ override_const_property(arg_pack, _weight_map, g, edge_weight),
+ override_const_property(arg_pack, _vertex_index_map, g, vertex_index),
+ detail::make_color_map_from_arg_pack(g, arg_pack),
+ arg_pack[_distance_compare | std::less()],
+ arg_pack[_distance_combine | closed_plus()],
+ arg_pack[_distance_inf | (std::numeric_limits::max)()],
+ arg_pack[_distance_zero | D()]);
}
} // namespace boost
diff --git a/include/boost/graph/named_function_params.hpp b/include/boost/graph/named_function_params.hpp
index 6f890811..d3be9f22 100644
--- a/include/boost/graph/named_function_params.hpp
+++ b/include/boost/graph/named_function_params.hpp
@@ -393,12 +393,19 @@ BOOST_BGL_DECLARE_NAMED_PARAMS
};
template
- typename override_const_property_t<
- typename boost::parameter::value_type::type,
- Prop,
- Graph,
- boost::detail::parameter_exists::value
- >::result_type
+ struct override_const_property_result {
+ typedef
+ typename override_const_property_t<
+ typename boost::parameter::value_type::type,
+ Prop,
+ Graph,
+ boost::detail::parameter_exists::value
+ >::result_type
+ type;
+ };
+
+ template
+ typename override_const_property_result::type
override_const_property(const ArgPack& ap, const boost::parameter::keyword& t, const Graph& g, Prop) {
return override_const_property_t<
typename boost::parameter::value_type::type,
@@ -421,12 +428,19 @@ BOOST_BGL_DECLARE_NAMED_PARAMS
};
template
- typename override_property_t<
- typename boost::parameter::value_type::type,
- Prop,
- Graph,
- boost::detail::parameter_exists::value
- >::result_type
+ struct override_property_result {
+ typedef
+ typename override_property_t<
+ typename boost::parameter::value_type::type,
+ Prop,
+ Graph,
+ boost::detail::parameter_exists::value
+ >::result_type
+ type;
+ };
+
+ template
+ typename override_property_result::type
override_property(const ArgPack& ap, const boost::parameter::keyword& t, const Graph& g, Prop prop) {
return override_property_t<
typename boost::parameter::value_type::type,