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