13 template<
class Graph,
class EdgeIndexMap>
17 typedef typename boost::graph_traits<Graph>::edge_descriptor Edge;
18 typedef boost::readable_property_map_tag category;
19 typedef Edge key_type;
20 typedef size_t value_type;
21 typedef size_t reference;
23 EdgeIndexMap edge_index_map;
25 g(g), edge_index_map(edge_index_map)
30 template<
class Graph,
class EdgeIndexMap>
31 inline const size_t get(
33 const typename boost::graph_traits<Graph>::edge_descriptor & e)
35 return (
get(map.edge_index_map,e) << 1)
36 + ((source(e,map.g)<target(e,map.g)) ? 0 : 1);
57 template <
class Graph,
class ActualWMap,
58 class StartPredecessorMap,
class StartDistanceMap,
class StartDistanceLookaheadMap,
59 class GoalPredecessorMap,
class GoalDistanceMap,
class GoalDistanceLookaheadMap,
60 class EdgeIndexMap,
class EdgeVectorMap,
61 typename CompareFunction,
typename CombineFunction,
62 class IncBiVisitor,
class IncBiBalancer>
66 typedef typename boost::graph_traits<Graph>::vertex_descriptor Vertex;
67 typedef typename boost::graph_traits<Graph>::edge_descriptor Edge;
68 typedef typename boost::property_traits<ActualWMap>::value_type weight_type;
69 typedef typename boost::property_map<Graph, boost::vertex_index_t>::type VIndexMap;
75 StartPredecessorMap start_predecessor;
76 StartDistanceMap start_distance;
77 GoalPredecessorMap goal_predecessor;
78 GoalDistanceMap goal_distance;
79 EdgeVectorMap edge_vector_map;
84 StartPredecessorMap,StartDistanceMap,StartDistanceLookaheadMap,
85 GoalPredecessorMap,GoalDistanceMap,GoalDistanceLookaheadMap,
90 CompareFunction, CombineFunction,
91 weight_type, weight_type,
92 IncBiVisitor, IncBiBalancer
96 Graph & g, Vertex v_start, Vertex v_goal, ActualWMap w_map,
97 StartPredecessorMap start_predecessor,
98 StartDistanceMap start_distance, StartDistanceLookaheadMap start_distance_lookahead,
99 GoalPredecessorMap goal_predecessor,
100 GoalDistanceMap goal_distance, GoalDistanceLookaheadMap goal_distance_lookahead,
101 EdgeIndexMap edge_index_map,
102 EdgeVectorMap edge_vector_map,
103 weight_type goal_margin,
104 CompareFunction compare, CombineFunction combine,
105 weight_type inf, weight_type zero,
106 IncBiVisitor vis, IncBiBalancer balancer):
107 g(g), v_start(v_start), v_goal(v_goal),
109 start_predecessor(start_predecessor),
110 start_distance(start_distance),
111 goal_predecessor(goal_predecessor),
112 goal_distance(goal_distance),
113 edge_vector_map(edge_vector_map),
115 incbi(g, v_start, v_goal,
116 start_predecessor, start_distance, start_distance_lookahead,
117 goal_predecessor, goal_distance, goal_distance_lookahead,
119 get(boost::vertex_index, g),
125 compare, combine, inf, zero,
131 template <
typename LazySPWMap>
132 weight_type solve(
const Graph & g, Vertex v_start, Vertex v_goal,
133 LazySPWMap wmap, std::vector<Edge> & path)
135 std::pair<size_t,bool> spresult =
incbi.compute_shortest_path();
138 if (!spresult.second)
142 size_t eidx_actual = spresult.first >> 1;
143 Edge e =
get(edge_vector_map, eidx_actual);
145 Vertex v_startside = source(e, g);
146 Vertex v_goalside = target(e, g);
147 unsigned char goalside_is_lower = (v_goalside < v_startside) ? 1 : 0;
148 unsigned char goalside_shouldbe_lower = spresult.first & 1;
150 if (goalside_is_lower ^ goalside_shouldbe_lower)
152 Vertex v_temp = v_startside;
153 v_startside = v_goalside;
155 e = edge(target(e,g),source(e,g),g).first;
161 for (Vertex v_walk=v_startside; v_walk!=v_start;)
163 Vertex v_pred =
get(start_predecessor,v_walk);
164 std::pair<Edge,bool> ret = edge(v_pred, v_walk, g);
165 BOOST_ASSERT(ret.second);
166 path.push_back(ret.first);
169 std::reverse(path.begin(),path.end());
172 std::pair<Edge,bool> ret = edge(v_startside, v_goalside, g);
173 BOOST_ASSERT(ret.second);
174 path.push_back(ret.first);
177 for (Vertex v_walk=v_goalside; v_walk!=v_goal;)
179 Vertex v_succ =
get(goal_predecessor,v_walk);
180 std::pair<Edge,bool> ret = edge(v_walk, v_succ, g);
181 BOOST_ASSERT(ret.second);
182 path.push_back(ret.first);
186 return get(start_distance,v_startside) +
get(w_map,e) +
get(goal_distance,v_goalside);
189 void update_notify(Edge euv)
191 Vertex u = source(euv,g);
192 Vertex v = target(euv,g);
194 weight_type wuv =
get(w_map,euv);
195 incbi.start_update_predecessor(u, v, wuv);
196 incbi.start_update_vertex(v);
197 incbi.goal_update_successor(u, v, wuv);
198 incbi.goal_update_vertex(u);
199 incbi.update_edge(euv);
201 Edge evu = edge(v,u,g).first;
202 weight_type wvu =
get(w_map,evu);
203 incbi.start_update_predecessor(v, u, wvu);
204 incbi.start_update_vertex(u);
205 incbi.goal_update_successor(v, u, wvu);
206 incbi.goal_update_vertex(v);
207 incbi.update_edge(evu);
211 template <
class Graph,
class ActualWMap,
212 class StartPredecessorMap,
class StartDistanceMap,
class StartDistanceLookaheadMap,
213 class GoalPredecessorMap,
class GoalDistanceMap,
class GoalDistanceLookaheadMap,
214 class EdgeIndexMap,
class EdgeVectorMap,
215 typename CompareFunction,
typename CombineFunction,
216 class IncBiVisitor,
class IncBiBalancer>
217 lazysp_incsp_incbi<Graph,ActualWMap,StartPredecessorMap,StartDistanceMap,StartDistanceLookaheadMap,GoalPredecessorMap,GoalDistanceMap,GoalDistanceLookaheadMap,EdgeIndexMap,EdgeVectorMap,CompareFunction,CombineFunction,IncBiVisitor,IncBiBalancer>
218 make_lazysp_incsp_incbi(
220 typename boost::graph_traits<Graph>::vertex_descriptor v_start,
221 typename boost::graph_traits<Graph>::vertex_descriptor v_goal,
223 StartPredecessorMap start_predecessor,
224 StartDistanceMap start_distance, StartDistanceLookaheadMap start_distance_lookahead,
225 GoalPredecessorMap goal_predecessor,
226 GoalDistanceMap goal_distance, GoalDistanceLookaheadMap goal_distance_lookahead,
227 EdgeIndexMap edge_index_map, EdgeVectorMap edge_vector_map,
228 typename boost::property_traits<ActualWMap>::value_type goal_margin,
229 CompareFunction compare, CombineFunction combine,
230 typename boost::property_traits<ActualWMap>::value_type inf,
231 typename boost::property_traits<ActualWMap>::value_type zero,
232 IncBiVisitor vis, IncBiBalancer balancer)
234 return lazysp_incsp_incbi<Graph,ActualWMap,StartPredecessorMap,StartDistanceMap,StartDistanceLookaheadMap,GoalPredecessorMap,GoalDistanceMap,GoalDistanceLookaheadMap,EdgeIndexMap,EdgeVectorMap,CompareFunction,CombineFunction,IncBiVisitor,IncBiBalancer>(
235 g, v_start, v_goal, w_map, start_predecessor, start_distance, start_distance_lookahead, goal_predecessor, goal_distance, goal_distance_lookahead, edge_index_map, edge_vector_map, goal_margin, compare, combine, inf, zero, vis, balancer);
Definition: lazysp_incsp_incbi.h:14
Adaptor to use pr_bgl::incbi as the inner sp algorithm for pr_bgl::lazysp.
Definition: lazysp_incsp_incbi.h:63
This class implements incremental bidirectional Dijkstra's search for the single-pair shortest path p...
Definition: incbi.h:50