@@ -228,40 +228,42 @@ retrievePackedPathFromHeap(const SearchEngineData<Algorithm>::QueryHeap &forward
228228template <bool DIRECTION, typename Algorithm, typename ... Args>
229229void relaxOutgoingEdges (const DataFacade<Algorithm> &facade,
230230 typename SearchEngineData<Algorithm>::QueryHeap &forward_heap,
231- const NodeID node,
232- const EdgeWeight weight,
231+ const typename SearchEngineData<Algorithm>::QueryHeap::HeapNode &heapNode,
233232 Args... args)
234233{
235234 const auto &partition = facade.GetMultiLevelPartition ();
236235 const auto &cells = facade.GetCellStorage ();
237236 const auto &metric = facade.GetCellMetric ();
238237
239- const auto level = getNodeQueryLevel (partition, node, args...);
238+ const auto level = getNodeQueryLevel (partition, heapNode. node , args...);
240239
241- if (level >= 1 && !forward_heap. GetData (node) .from_clique_arc )
240+ if (level >= 1 && !heapNode. data .from_clique_arc )
242241 {
243242 if (DIRECTION == FORWARD_DIRECTION)
244243 {
245244 // Shortcuts in forward direction
246- const auto &cell = cells.GetCell (metric, level, partition.GetCell (level, node));
245+ const auto &cell =
246+ cells.GetCell (metric, level, partition.GetCell (level, heapNode.node ));
247247 auto destination = cell.GetDestinationNodes ().begin ();
248- for (auto shortcut_weight : cell.GetOutWeight (node))
248+ for (auto shortcut_weight : cell.GetOutWeight (heapNode. node ))
249249 {
250250 BOOST_ASSERT (destination != cell.GetDestinationNodes ().end ());
251251 const NodeID to = *destination;
252252
253- if (shortcut_weight != INVALID_EDGE_WEIGHT && node != to)
253+ if (shortcut_weight != INVALID_EDGE_WEIGHT && heapNode. node != to)
254254 {
255- const EdgeWeight to_weight = weight + shortcut_weight;
256- BOOST_ASSERT (to_weight >= weight);
257- if (!forward_heap.WasInserted (to))
255+ const EdgeWeight to_weight = heapNode.weight + shortcut_weight;
256+ BOOST_ASSERT (to_weight >= heapNode.weight );
257+ const auto toHeapNode = forward_heap.GetHeapNodeIfWasInserted (to);
258+ if (!toHeapNode)
258259 {
259- forward_heap.Insert (to, to_weight, {node, true });
260+ forward_heap.Insert (to, to_weight, {heapNode. node , true });
260261 }
261- else if (to_weight < forward_heap. GetKey (to) )
262+ else if (to_weight < toHeapNode-> weight )
262263 {
263- forward_heap.GetData (to) = {node, true };
264- forward_heap.DecreaseKey (to, to_weight);
264+ toHeapNode->data = {heapNode.node , true };
265+ toHeapNode->weight = to_weight;
266+ forward_heap.DecreaseKey (*toHeapNode);
265267 }
266268 }
267269 ++destination;
@@ -270,25 +272,28 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
270272 else
271273 {
272274 // Shortcuts in backward direction
273- const auto &cell = cells.GetCell (metric, level, partition.GetCell (level, node));
275+ const auto &cell =
276+ cells.GetCell (metric, level, partition.GetCell (level, heapNode.node ));
274277 auto source = cell.GetSourceNodes ().begin ();
275- for (auto shortcut_weight : cell.GetInWeight (node))
278+ for (auto shortcut_weight : cell.GetInWeight (heapNode. node ))
276279 {
277280 BOOST_ASSERT (source != cell.GetSourceNodes ().end ());
278281 const NodeID to = *source;
279282
280- if (shortcut_weight != INVALID_EDGE_WEIGHT && node != to)
283+ if (shortcut_weight != INVALID_EDGE_WEIGHT && heapNode. node != to)
281284 {
282- const EdgeWeight to_weight = weight + shortcut_weight;
283- BOOST_ASSERT (to_weight >= weight);
284- if (!forward_heap.WasInserted (to))
285+ const EdgeWeight to_weight = heapNode.weight + shortcut_weight;
286+ BOOST_ASSERT (to_weight >= heapNode.weight );
287+ const auto toHeapNode = forward_heap.GetHeapNodeIfWasInserted (to);
288+ if (!toHeapNode)
285289 {
286- forward_heap.Insert (to, to_weight, {node, true });
290+ forward_heap.Insert (to, to_weight, {heapNode. node , true });
287291 }
288- else if (to_weight < forward_heap. GetKey (to) )
292+ else if (to_weight < toHeapNode-> weight )
289293 {
290- forward_heap.GetData (to) = {node, true };
291- forward_heap.DecreaseKey (to, to_weight);
294+ toHeapNode->data = {heapNode.node , true };
295+ toHeapNode->weight = to_weight;
296+ forward_heap.DecreaseKey (*toHeapNode);
292297 }
293298 }
294299 ++source;
@@ -297,7 +302,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
297302 }
298303
299304 // Boundary edges
300- for (const auto edge : facade.GetBorderEdgeRange (level, node))
305+ for (const auto edge : facade.GetBorderEdgeRange (level, heapNode. node ))
301306 {
302307 const auto &edge_data = facade.GetEdgeData (edge);
303308
@@ -310,21 +315,23 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
310315 checkParentCellRestriction (partition.GetCell (level + 1 , to), args...))
311316 {
312317 const auto node_weight =
313- facade.GetNodeWeight (DIRECTION == FORWARD_DIRECTION ? node : to);
318+ facade.GetNodeWeight (DIRECTION == FORWARD_DIRECTION ? heapNode. node : to);
314319 const auto turn_penalty = facade.GetWeightPenaltyForEdgeID (edge_data.turn_id );
315320
316321 // TODO: BOOST_ASSERT(edge_data.weight == node_weight + turn_penalty);
317322
318- const EdgeWeight to_weight = weight + node_weight + turn_penalty;
323+ const EdgeWeight to_weight = heapNode. weight + node_weight + turn_penalty;
319324
320- if (!forward_heap.WasInserted (to))
325+ const auto toHeapNode = forward_heap.GetHeapNodeIfWasInserted (to);
326+ if (!toHeapNode)
321327 {
322- forward_heap.Insert (to, to_weight, {node, false });
328+ forward_heap.Insert (to, to_weight, {heapNode. node , false });
323329 }
324- else if (to_weight < forward_heap. GetKey (to) )
330+ else if (to_weight < toHeapNode-> weight )
325331 {
326- forward_heap.GetData (to) = {node, false };
327- forward_heap.DecreaseKey (to, to_weight);
332+ toHeapNode->data = {heapNode.node , false };
333+ toHeapNode->weight = to_weight;
334+ forward_heap.DecreaseKey (*toHeapNode);
328335 }
329336 }
330337 }
@@ -341,34 +348,35 @@ void routingStep(const DataFacade<Algorithm> &facade,
341348 const bool force_loop_reverse,
342349 Args... args)
343350{
344- const auto node = forward_heap.DeleteMin ();
345- const auto weight = forward_heap. GetKey (node) ;
351+ const auto heapNode = forward_heap.DeleteMinGetHeapNode ();
352+ const auto weight = heapNode. weight ;
346353
347- BOOST_ASSERT (!facade.ExcludeNode (node));
354+ BOOST_ASSERT (!facade.ExcludeNode (heapNode. node ));
348355
349356 // Upper bound for the path source -> target with
350357 // weight(source -> node) = weight weight(to -> target) ≤ reverse_weight
351358 // is weight + reverse_weight
352359 // More tighter upper bound requires additional condition reverse_heap.WasRemoved(to)
353360 // with weight(to -> target) = reverse_weight and all weights ≥ 0
354- if (reverse_heap.WasInserted (node))
361+ const auto reverseHeapNode = reverse_heap.GetHeapNodeIfWasInserted (heapNode.node );
362+ if (reverseHeapNode)
355363 {
356- auto reverse_weight = reverse_heap. GetKey (node) ;
364+ auto reverse_weight = reverseHeapNode-> weight ;
357365 auto path_weight = weight + reverse_weight;
358366
359367 // MLD uses loops forcing only to prune single node paths in forward and/or
360368 // backward direction (there is no need to force loops in MLD but in CH)
361- if (!(force_loop_forward && forward_heap. GetData (node) .parent == node) &&
362- !(force_loop_reverse && reverse_heap. GetData (node). parent == node) &&
369+ if (!(force_loop_forward && heapNode. data .parent == heapNode. node ) &&
370+ !(force_loop_reverse && reverseHeapNode-> data . parent == heapNode. node ) &&
363371 (path_weight >= 0 ) && (path_weight < path_upper_bound))
364372 {
365- middle_node = node;
373+ middle_node = heapNode. node ;
366374 path_upper_bound = path_weight;
367375 }
368376 }
369377
370378 // Relax outgoing edges from node
371- relaxOutgoingEdges<DIRECTION>(facade, forward_heap, node, weight , args...);
379+ relaxOutgoingEdges<DIRECTION>(facade, forward_heap, heapNode , args...);
372380}
373381
374382// With (s, middle, t) we trace back the paths middle -> s and middle -> t.
0 commit comments