-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,32 +27,32 @@ void routingStep(const datafacade::ContiguousInternalMemoryDataFacade<algorithm: | |
SearchEngineData::MultiLayerDijkstraHeap &reverse_heap, | ||
const std::pair<LevelID, CellID> &parent_cell, | ||
NodeID &middle_node, | ||
EdgeWeight &path_upper_bound, | ||
EdgeWeight &forward_upper_bound, | ||
EdgeWeight &reverse_upper_bound) | ||
EdgeWeight &path_upper_bound) | ||
{ | ||
const auto node = forward_heap.DeleteMin(); | ||
const auto weight = forward_heap.GetKey(node); | ||
|
||
auto update_upper_bounds = [&](NodeID to, EdgeWeight forward_weight, EdgeWeight edge_weight) { | ||
// Upper bound for the path source -> target with | ||
// weight(source -> node) = forward_weight, weight(node -> to) = edge_weight and | ||
// weight(to -> target) ≤ reverse_weight is forward_weight + edge_weight + reverse_weight | ||
// More tighter upper bound requires additional condition reverse_heap.WasRemoved(to) | ||
// with weight(to -> target) = reverse_weight and all weights ≥ 0 | ||
if (reverse_heap.WasInserted(to)) | ||
// Upper bound for the path source -> target with | ||
// weight(source -> node) = weight weight(to -> target) ≤ reverse_weight | ||
// is weight + reverse_weight | ||
// More tighter upper bound requires additional condition reverse_heap.WasRemoved(to) | ||
// with weight(to -> target) = reverse_weight and all weights ≥ 0 | ||
if (reverse_heap.WasInserted(node)) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
oxidase
Author
Contributor
|
||
{ | ||
auto reverse_weight = reverse_heap.GetKey(node); | ||
auto path_weight = weight + reverse_weight; | ||
if (path_weight >= 0 && path_weight < path_upper_bound) | ||
{ | ||
auto reverse_weight = reverse_heap.GetKey(to); | ||
auto path_weight = forward_weight + edge_weight + reverse_weight; | ||
if (path_weight >= 0 && path_weight < path_upper_bound) | ||
{ | ||
middle_node = to; | ||
path_upper_bound = path_weight; | ||
forward_upper_bound = forward_weight + edge_weight; | ||
reverse_upper_bound = reverse_weight + edge_weight; | ||
} | ||
middle_node = node; | ||
path_upper_bound = path_weight; | ||
} | ||
}; | ||
} | ||
|
||
if (weight > path_upper_bound) | ||
{ | ||
forward_heap.DeleteAll(); | ||
return; | ||
} | ||
|
||
const auto &node_data = forward_heap.GetData(node); | ||
const auto level = node_data.level; | ||
|
@@ -61,9 +61,6 @@ void routingStep(const datafacade::ContiguousInternalMemoryDataFacade<algorithm: | |
(node_data.parent == node || // is the first point of the path | ||
node_data.edge_id != SPECIAL_EDGEID); // or an overlay entreé point | ||
|
||
// Edge case: single node path | ||
update_upper_bounds(node, weight, 0); | ||
|
||
if (check_overlay_edges) | ||
{ | ||
if (DIRECTION == FORWARD_DIRECTION) | ||
|
@@ -81,13 +78,11 @@ void routingStep(const datafacade::ContiguousInternalMemoryDataFacade<algorithm: | |
if (!forward_heap.WasInserted(to)) | ||
{ | ||
forward_heap.Insert(to, to_weight, {node, level}); | ||
update_upper_bounds(to, weight, shortcut_weight); | ||
} | ||
else if (to_weight < forward_heap.GetKey(to)) | ||
{ | ||
forward_heap.GetData(to) = {node, level}; | ||
forward_heap.DecreaseKey(to, to_weight); | ||
update_upper_bounds(to, weight, shortcut_weight); | ||
} | ||
} | ||
++destination; | ||
|
@@ -108,13 +103,11 @@ void routingStep(const datafacade::ContiguousInternalMemoryDataFacade<algorithm: | |
if (!forward_heap.WasInserted(to)) | ||
{ | ||
forward_heap.Insert(to, to_weight, {node, level}); | ||
update_upper_bounds(to, weight, shortcut_weight); | ||
} | ||
else if (to_weight < forward_heap.GetKey(to)) | ||
{ | ||
forward_heap.GetData(to) = {node, level}; | ||
forward_heap.DecreaseKey(to, to_weight); | ||
update_upper_bounds(to, weight, shortcut_weight); | ||
} | ||
} | ||
++source; | ||
|
@@ -144,13 +137,11 @@ void routingStep(const datafacade::ContiguousInternalMemoryDataFacade<algorithm: | |
if (!forward_heap.WasInserted(to)) | ||
{ | ||
forward_heap.Insert(to, to_weight, {node, to_level, edge}); | ||
update_upper_bounds(to, weight, edge_data.weight); | ||
} | ||
else if (to_weight < forward_heap.GetKey(to)) | ||
{ | ||
forward_heap.GetData(to) = {node, to_level, edge}; | ||
forward_heap.DecreaseKey(to, to_weight); | ||
update_upper_bounds(to, weight, edge_data.weight); | ||
} | ||
} | ||
} | ||
|
@@ -164,44 +155,25 @@ auto search(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::MLD> | |
SearchEngineData::MultiLayerDijkstraHeap &reverse_heap, | ||
const std::pair<LevelID, CellID> &parent_cell) | ||
{ | ||
BOOST_ASSERT(!forward_heap.Empty() && forward_heap.MinKey() < INVALID_EDGE_WEIGHT); | ||
BOOST_ASSERT(!reverse_heap.Empty() && reverse_heap.MinKey() < INVALID_EDGE_WEIGHT); | ||
|
||
// run two-Target Dijkstra routing step. | ||
NodeID middle = SPECIAL_NODEID; | ||
EdgeWeight weight = INVALID_EDGE_WEIGHT; | ||
EdgeWeight forward_search_radius = INVALID_EDGE_WEIGHT; | ||
EdgeWeight reverse_search_radius = INVALID_EDGE_WEIGHT; | ||
bool progress; | ||
do | ||
while ((forward_heap.Size() + reverse_heap.Size() > 0)) | ||
This comment has been minimized.
Sorry, something went wrong.
TheMarex
Member
|
||
{ | ||
progress = false; | ||
if (!forward_heap.Empty() && (forward_heap.MinKey() < forward_search_radius)) | ||
if (!forward_heap.Empty()) | ||
{ | ||
progress = true; | ||
routingStep<FORWARD_DIRECTION>(facade, | ||
partition, | ||
cells, | ||
forward_heap, | ||
reverse_heap, | ||
parent_cell, | ||
middle, | ||
weight, | ||
forward_search_radius, | ||
reverse_search_radius); | ||
routingStep<FORWARD_DIRECTION>( | ||
facade, partition, cells, forward_heap, reverse_heap, parent_cell, middle, weight); | ||
} | ||
if (!reverse_heap.Empty() && (reverse_heap.MinKey() < reverse_search_radius)) | ||
if (!reverse_heap.Empty()) | ||
{ | ||
progress = true; | ||
routingStep<REVERSE_DIRECTION>(facade, | ||
partition, | ||
cells, | ||
reverse_heap, | ||
forward_heap, | ||
parent_cell, | ||
middle, | ||
weight, | ||
reverse_search_radius, | ||
forward_search_radius); | ||
routingStep<REVERSE_DIRECTION>( | ||
facade, partition, cells, reverse_heap, forward_heap, parent_cell, middle, weight); | ||
} | ||
} while (progress); | ||
}; | ||
|
||
// No path found for both target nodes? | ||
if (weight == INVALID_EDGE_WEIGHT || SPECIAL_NODEID == middle) | ||
|
Needs to be
WasRemoved(node)