Changes made

This commit is contained in:
xlaussel
2020-11-23 22:33:08 +01:00
parent a3f1c2afb0
commit 13067844ee
7 changed files with 216 additions and 145 deletions
@@ -62,8 +62,8 @@ void alternativeRoutingStep(const DataFacade<Algorithm> &facade,
QueryHeap &forward_heap = DIRECTION == FORWARD_DIRECTION ? heap1 : heap2;
QueryHeap &reverse_heap = DIRECTION == FORWARD_DIRECTION ? heap2 : heap1;
const NodeID node = forward_heap.DeleteMin();
const EdgeWeight weight = forward_heap.GetKey(node);
auto & heapNode=forward_heap.DeleteMinGetHeapNode();
const EdgeWeight weight = heapNode.weight;
const auto scaled_weight =
static_cast<EdgeWeight>((weight + min_edge_offset) / (1. + VIAPATH_EPSILON));
@@ -74,35 +74,36 @@ void alternativeRoutingStep(const DataFacade<Algorithm> &facade,
return;
}
search_space.emplace_back(forward_heap.GetData(node).parent, node);
search_space.emplace_back(heapNode.data.parent, heapNode.node);
if (reverse_heap.WasInserted(node))
const auto& reverseHeapNode=reverse_heap.WasInsertedGetHeapNode(heapNode.node);
if (reverseHeapNode)
{
search_space_intersection.emplace_back(node);
const EdgeWeight new_weight = reverse_heap.GetKey(node) + weight;
search_space_intersection.emplace_back(heapNode.node);
const EdgeWeight new_weight = reverseHeapNode->weight + weight;
if (new_weight < *upper_bound_to_shortest_path_weight)
{
if (new_weight >= 0)
{
*middle_node = node;
*middle_node = heapNode.node;
*upper_bound_to_shortest_path_weight = new_weight;
}
else
{
// check whether there is a loop present at the node
const auto loop_weight = std::get<0>(getLoopWeight<false>(facade, node));
const auto loop_weight = std::get<0>(getLoopWeight<false>(facade, heapNode.node));
const EdgeWeight new_weight_with_loop = new_weight + loop_weight;
if (loop_weight != INVALID_EDGE_WEIGHT &&
new_weight_with_loop <= *upper_bound_to_shortest_path_weight)
{
*middle_node = node;
*middle_node = heapNode.node;
*upper_bound_to_shortest_path_weight = loop_weight;
}
}
}
}
for (auto edge : facade.GetAdjacentEdgeRange(node))
for (auto edge : facade.GetAdjacentEdgeRange(heapNode.node))
{
const auto &data = facade.GetEdgeData(edge);
if (DIRECTION == FORWARD_DIRECTION ? data.forward : data.backward)
@@ -113,18 +114,20 @@ void alternativeRoutingStep(const DataFacade<Algorithm> &facade,
BOOST_ASSERT(edge_weight > 0);
const EdgeWeight to_weight = weight + edge_weight;
const auto& toHeapNode=forward_heap.WasInsertedGetHeapNode(to);
// New Node discovered -> Add to Heap + Node Info Storage
if (!forward_heap.WasInserted(to))
if (!toHeapNode)
{
forward_heap.Insert(to, to_weight, node);
forward_heap.Insert(to, to_weight, heapNode.node);
}
// Found a shorter Path -> Update weight
else if (to_weight < forward_heap.GetKey(to))
{
// new parent
forward_heap.GetData(to).parent = node;
toHeapNode->data.parent = heapNode.node;
// decreased weight
forward_heap.DecreaseKey(to, to_weight);
toHeapNode->weight=to_weight;
forward_heap.DecreaseKey(*toHeapNode);
}
}
}