2121#include < boost/graph/relax.hpp>
2222#include < boost/graph/exception.hpp>
2323#include < boost/graph/breadth_first_search.hpp>
24+ #include < boost/graph/detail/visitor_wrapper.hpp>
2425#include < boost/graph/iteration_macros.hpp>
2526#include < boost/graph/detail/d_ary_heap.hpp>
2627#include < boost/graph/property_maps/constant_property_map.hpp>
@@ -50,7 +51,7 @@ template < class Graph, class CostType > class astar_heuristic
5051 typedef Vertex argument_type;
5152 typedef CostType result_type;
5253 astar_heuristic () {}
53- CostType operator ()(Vertex u ) { return static_cast < CostType >(0 ); }
54+ CostType operator ()(Vertex /* u */ ) { return static_cast < CostType >(0 ); }
5455};
5556
5657template < class Visitor , class Graph > struct AStarVisitorConcept
@@ -92,11 +93,11 @@ class astar_visitor : public bfs_visitor< Visitors >
9293 }
9394
9495private:
95- template < class Edge , class Graph > void tree_edge (Edge e , const Graph& g )
96+ template < class Edge , class Graph > void tree_edge (Edge /* e */ , const Graph& /* g */ )
9697 {
9798 }
9899 template < class Edge , class Graph >
99- void non_tree_edge (Edge e , const Graph& g )
100+ void non_tree_edge (Edge /* e */ , const Graph& /* g */ )
100101 {
101102 }
102103};
@@ -144,29 +145,29 @@ namespace detail
144145 template < class Vertex , class Graph >
145146 void initialize_vertex (Vertex u, const Graph& g)
146147 {
147- m_vis .initialize_vertex (u, g);
148+ user_vis () .initialize_vertex (u, g);
148149 }
149150 template < class Vertex , class Graph >
150151 void discover_vertex (Vertex u, const Graph& g)
151152 {
152- m_vis .discover_vertex (u, g);
153+ user_vis () .discover_vertex (u, g);
153154 }
154155 template < class Vertex , class Graph >
155156 void examine_vertex (Vertex u, const Graph& g)
156157 {
157- m_vis .examine_vertex (u, g);
158+ user_vis () .examine_vertex (u, g);
158159 }
159160 template < class Vertex , class Graph >
160161 void finish_vertex (Vertex u, const Graph& g)
161162 {
162- m_vis .finish_vertex (u, g);
163+ user_vis () .finish_vertex (u, g);
163164 }
164165 template < class Edge , class Graph >
165166 void examine_edge (Edge e, const Graph& g)
166167 {
167168 if (m_compare (get (m_weight, e), m_zero))
168169 BOOST_THROW_EXCEPTION (negative_edge ());
169- m_vis .examine_edge (e, g);
170+ user_vis () .examine_edge (e, g);
170171 }
171172 template < class Edge , class Graph >
172173 void non_tree_edge (Edge, const Graph&)
@@ -182,13 +183,13 @@ namespace detail
182183
183184 if (m_decreased)
184185 {
185- m_vis .edge_relaxed (e, g);
186+ user_vis () .edge_relaxed (e, g);
186187 put (m_cost, target (e, g),
187188 m_combine (
188189 get (m_distance, target (e, g)), m_h (target (e, g))));
189190 }
190191 else
191- m_vis .edge_not_relaxed (e, g);
192+ user_vis () .edge_not_relaxed (e, g);
192193 }
193194
194195 template < class Edge , class Graph >
@@ -204,10 +205,10 @@ namespace detail
204205 m_combine (
205206 get (m_distance, target (e, g)), m_h (target (e, g))));
206207 m_Q.update (target (e, g));
207- m_vis .edge_relaxed (e, g);
208+ user_vis () .edge_relaxed (e, g);
208209 }
209210 else
210- m_vis .edge_not_relaxed (e, g);
211+ user_vis () .edge_not_relaxed (e, g);
211212 }
212213
213214 template < class Edge , class Graph >
@@ -219,16 +220,21 @@ namespace detail
219220
220221 if (m_decreased)
221222 {
222- m_vis .edge_relaxed (e, g);
223+ user_vis () .edge_relaxed (e, g);
223224 put (m_cost, target (e, g),
224225 m_combine (
225226 get (m_distance, target (e, g)), m_h (target (e, g))));
226227 m_Q.push (target (e, g));
227228 put (m_color, target (e, g), Color::gray ());
228- m_vis .black_target (e, g);
229+ user_vis () .black_target (e, g);
229230 }
230231 else
231- m_vis.edge_not_relaxed (e, g);
232+ user_vis ().edge_not_relaxed (e, g);
233+ }
234+
235+ auto & user_vis ()
236+ {
237+ return ::boost::graph::detail::deref_visitor (m_vis);
232238 }
233239
234240 AStarHeuristic m_h;
@@ -310,38 +316,40 @@ inline void astar_search_no_init_tree(const VertexListGraph& g,
310316 null_property_map< std::pair< Distance, Vertex >, std::size_t >(),
311317 compare);
312318
313- vis.discover_vertex (s, g);
319+ auto & vis_ref = ::boost::graph::detail::deref_visitor (vis);
320+
321+ vis_ref.discover_vertex (s, g);
314322 Q.push (std::make_pair (get (cost, s), s));
315323 while (!Q.empty ())
316324 {
317325 Vertex v;
318326 Distance v_rank;
319327 boost::tie (v_rank, v) = Q.top ();
320328 Q.pop ();
321- vis .examine_vertex (v, g);
329+ vis_ref .examine_vertex (v, g);
322330 BGL_FORALL_OUTEDGES_T (v, e, g, VertexListGraph)
323331 {
324332 Vertex w = target (e, g);
325- vis .examine_edge (e, g);
333+ vis_ref .examine_edge (e, g);
326334 Distance e_weight = get (weight, e);
327335 if (compare (e_weight, zero))
328336 BOOST_THROW_EXCEPTION (negative_edge ());
329337 bool decreased
330338 = relax (e, g, weight, predecessor, distance, combine, compare);
331339 if (decreased)
332340 {
333- vis .edge_relaxed (e, g);
341+ vis_ref .edge_relaxed (e, g);
334342 Distance w_rank = combine (get (distance, w), h (w));
335343 put (cost, w, w_rank);
336- vis .discover_vertex (w, g);
344+ vis_ref .discover_vertex (w, g);
337345 Q.push (std::make_pair (w_rank, w));
338346 }
339347 else
340348 {
341- vis .edge_not_relaxed (e, g);
349+ vis_ref .edge_not_relaxed (e, g);
342350 }
343351 }
344- vis .finish_vertex (v, g);
352+ vis_ref .finish_vertex (v, g);
345353 }
346354}
347355
@@ -361,14 +369,16 @@ inline void astar_search(const VertexListGraph& g,
361369
362370 typedef typename property_traits< ColorMap >::value_type ColorValue;
363371 typedef color_traits< ColorValue > Color;
372+ auto & vis_ref = ::boost::graph::detail::deref_visitor (vis);
373+
364374 typename graph_traits< VertexListGraph >::vertex_iterator ui, ui_end;
365375 for (boost::tie (ui, ui_end) = vertices (g); ui != ui_end; ++ui)
366376 {
367377 put (color, *ui, Color::white ());
368378 put (distance, *ui, inf);
369379 put (cost, *ui, inf);
370380 put (predecessor, *ui, *ui);
371- vis .initialize_vertex (*ui, g);
381+ vis_ref .initialize_vertex (*ui, g);
372382 }
373383 put (distance, s, zero);
374384 put (cost, s, h (s));
@@ -390,13 +400,15 @@ inline void astar_search_tree(const VertexListGraph& g,
390400 CostZero zero)
391401{
392402
403+ auto & vis_ref = ::boost::graph::detail::deref_visitor (vis);
404+
393405 typename graph_traits< VertexListGraph >::vertex_iterator ui, ui_end;
394406 for (boost::tie (ui, ui_end) = vertices (g); ui != ui_end; ++ui)
395407 {
396408 put (distance, *ui, inf);
397409 put (cost, *ui, inf);
398410 put (predecessor, *ui, *ui);
399- vis .initialize_vertex (*ui, g);
411+ vis_ref .initialize_vertex (*ui, g);
400412 }
401413 put (distance, s, zero);
402414 put (cost, s, h (s));
0 commit comments