@@ -228,40 +228,42 @@ retrievePackedPathFromHeap(const SearchEngineData<Algorithm>::QueryHeap &forward
228
228
template <bool DIRECTION, typename Algorithm, typename ... Args>
229
229
void relaxOutgoingEdges (const DataFacade<Algorithm> &facade,
230
230
typename SearchEngineData<Algorithm>::QueryHeap &forward_heap,
231
- const NodeID node,
232
- const EdgeWeight weight,
231
+ const typename SearchEngineData<Algorithm>::QueryHeap::HeapNode &heapNode,
233
232
Args... args)
234
233
{
235
234
const auto &partition = facade.GetMultiLevelPartition ();
236
235
const auto &cells = facade.GetCellStorage ();
237
236
const auto &metric = facade.GetCellMetric ();
238
237
239
- const auto level = getNodeQueryLevel (partition, node, args...);
238
+ const auto level = getNodeQueryLevel (partition, heapNode. node , args...);
240
239
241
- if (level >= 1 && !forward_heap. GetData (node) .from_clique_arc )
240
+ if (level >= 1 && !heapNode. data .from_clique_arc )
242
241
{
243
242
if (DIRECTION == FORWARD_DIRECTION)
244
243
{
245
244
// 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 ));
247
247
auto destination = cell.GetDestinationNodes ().begin ();
248
- for (auto shortcut_weight : cell.GetOutWeight (node))
248
+ for (auto shortcut_weight : cell.GetOutWeight (heapNode. node ))
249
249
{
250
250
BOOST_ASSERT (destination != cell.GetDestinationNodes ().end ());
251
251
const NodeID to = *destination;
252
252
253
- if (shortcut_weight != INVALID_EDGE_WEIGHT && node != to)
253
+ if (shortcut_weight != INVALID_EDGE_WEIGHT && heapNode. node != to)
254
254
{
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)
258
259
{
259
- forward_heap.Insert (to, to_weight, {node, true });
260
+ forward_heap.Insert (to, to_weight, {heapNode. node , true });
260
261
}
261
- else if (to_weight < forward_heap. GetKey (to) )
262
+ else if (to_weight < toHeapNode-> weight )
262
263
{
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);
265
267
}
266
268
}
267
269
++destination;
@@ -270,25 +272,28 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
270
272
else
271
273
{
272
274
// 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 ));
274
277
auto source = cell.GetSourceNodes ().begin ();
275
- for (auto shortcut_weight : cell.GetInWeight (node))
278
+ for (auto shortcut_weight : cell.GetInWeight (heapNode. node ))
276
279
{
277
280
BOOST_ASSERT (source != cell.GetSourceNodes ().end ());
278
281
const NodeID to = *source;
279
282
280
- if (shortcut_weight != INVALID_EDGE_WEIGHT && node != to)
283
+ if (shortcut_weight != INVALID_EDGE_WEIGHT && heapNode. node != to)
281
284
{
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)
285
289
{
286
- forward_heap.Insert (to, to_weight, {node, true });
290
+ forward_heap.Insert (to, to_weight, {heapNode. node , true });
287
291
}
288
- else if (to_weight < forward_heap. GetKey (to) )
292
+ else if (to_weight < toHeapNode-> weight )
289
293
{
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);
292
297
}
293
298
}
294
299
++source;
@@ -297,7 +302,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
297
302
}
298
303
299
304
// Boundary edges
300
- for (const auto edge : facade.GetBorderEdgeRange (level, node))
305
+ for (const auto edge : facade.GetBorderEdgeRange (level, heapNode. node ))
301
306
{
302
307
const auto &edge_data = facade.GetEdgeData (edge);
303
308
@@ -310,21 +315,23 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
310
315
checkParentCellRestriction (partition.GetCell (level + 1 , to), args...))
311
316
{
312
317
const auto node_weight =
313
- facade.GetNodeWeight (DIRECTION == FORWARD_DIRECTION ? node : to);
318
+ facade.GetNodeWeight (DIRECTION == FORWARD_DIRECTION ? heapNode. node : to);
314
319
const auto turn_penalty = facade.GetWeightPenaltyForEdgeID (edge_data.turn_id );
315
320
316
321
// TODO: BOOST_ASSERT(edge_data.weight == node_weight + turn_penalty);
317
322
318
- const EdgeWeight to_weight = weight + node_weight + turn_penalty;
323
+ const EdgeWeight to_weight = heapNode. weight + node_weight + turn_penalty;
319
324
320
- if (!forward_heap.WasInserted (to))
325
+ const auto toHeapNode = forward_heap.GetHeapNodeIfWasInserted (to);
326
+ if (!toHeapNode)
321
327
{
322
- forward_heap.Insert (to, to_weight, {node, false });
328
+ forward_heap.Insert (to, to_weight, {heapNode. node , false });
323
329
}
324
- else if (to_weight < forward_heap. GetKey (to) )
330
+ else if (to_weight < toHeapNode-> weight )
325
331
{
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);
328
335
}
329
336
}
330
337
}
@@ -341,34 +348,35 @@ void routingStep(const DataFacade<Algorithm> &facade,
341
348
const bool force_loop_reverse,
342
349
Args... args)
343
350
{
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 ;
346
353
347
- BOOST_ASSERT (!facade.ExcludeNode (node));
354
+ BOOST_ASSERT (!facade.ExcludeNode (heapNode. node ));
348
355
349
356
// Upper bound for the path source -> target with
350
357
// weight(source -> node) = weight weight(to -> target) ≤ reverse_weight
351
358
// is weight + reverse_weight
352
359
// More tighter upper bound requires additional condition reverse_heap.WasRemoved(to)
353
360
// 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)
355
363
{
356
- auto reverse_weight = reverse_heap. GetKey (node) ;
364
+ auto reverse_weight = reverseHeapNode-> weight ;
357
365
auto path_weight = weight + reverse_weight;
358
366
359
367
// MLD uses loops forcing only to prune single node paths in forward and/or
360
368
// 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 ) &&
363
371
(path_weight >= 0 ) && (path_weight < path_upper_bound))
364
372
{
365
- middle_node = node;
373
+ middle_node = heapNode. node ;
366
374
path_upper_bound = path_weight;
367
375
}
368
376
}
369
377
370
378
// Relax outgoing edges from node
371
- relaxOutgoingEdges<DIRECTION>(facade, forward_heap, node, weight , args...);
379
+ relaxOutgoingEdges<DIRECTION>(facade, forward_heap, heapNode , args...);
372
380
}
373
381
374
382
// With (s, middle, t) we trace back the paths middle -> s and middle -> t.
0 commit comments