other improvements.

Variable renaming with better names
This commit is contained in:
xlaussel 2020-11-23 23:10:22 +01:00
parent 41af9615cd
commit e181cb325c
4 changed files with 27 additions and 27 deletions

View File

@ -255,16 +255,16 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
{ {
const EdgeWeight to_weight = weight + shortcut_weight; const EdgeWeight to_weight = weight + shortcut_weight;
BOOST_ASSERT(to_weight >= weight); BOOST_ASSERT(to_weight >= weight);
auto toNodeData= forward_heap.GetHeapNodeIfWasInserted(to); auto toHeapNode = forward_heap.GetHeapNodeIfWasInserted(to);
if (!toNodeData) if (!toHeapNode)
{ {
forward_heap.Insert(to, to_weight, {heapNode.node, true}); forward_heap.Insert(to, to_weight, {heapNode.node, true});
} }
else if (to_weight < forward_heap.GetKey(to)) else if (to_weight < toHeapNode->weight)
{ {
toNodeData->data = {heapNode.node, true}; toHeapNode->data = {heapNode.node, true};
toNodeData->weight=to_weight; toHeapNode->weight=to_weight;
forward_heap.DecreaseKey(*toNodeData); forward_heap.DecreaseKey(*toHeapNode);
} }
} }
++destination; ++destination;
@ -284,16 +284,16 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
{ {
const EdgeWeight to_weight = weight + shortcut_weight; const EdgeWeight to_weight = weight + shortcut_weight;
BOOST_ASSERT(to_weight >= weight); BOOST_ASSERT(to_weight >= weight);
auto toNodeData= forward_heap.GetHeapNodeIfWasInserted(to); auto toHeapNode = forward_heap.GetHeapNodeIfWasInserted(to);
if (!toNodeData) if (!toHeapNode)
{ {
forward_heap.Insert(to, to_weight, {heapNode.node, true}); forward_heap.Insert(to, to_weight, {heapNode.node, true});
} }
else if (to_weight < forward_heap.GetKey(to)) else if (to_weight < toHeapNode->weight)
{ {
toNodeData->data = {heapNode.node, true}; toHeapNode->data = {heapNode.node, true};
toNodeData->weight=to_weight; toHeapNode->weight=to_weight;
forward_heap.DecreaseKey(*toNodeData); forward_heap.DecreaseKey(*toHeapNode);
} }
} }
++source; ++source;
@ -322,16 +322,16 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
const EdgeWeight to_weight = weight + node_weight + turn_penalty; const EdgeWeight to_weight = weight + node_weight + turn_penalty;
auto toNodeData= forward_heap.GetHeapNodeIfWasInserted(to); auto toHeapNode = forward_heap.GetHeapNodeIfWasInserted(to);
if (!toNodeData) if (!toHeapNode)
{ {
forward_heap.Insert(to, to_weight, {heapNode.node, false}); forward_heap.Insert(to, to_weight, {heapNode.node, false});
} }
else if (to_weight < forward_heap.GetKey(to)) else if (to_weight < toHeapNode->weight)
{ {
toNodeData->data = {heapNode.node, false}; toHeapNode->data = {heapNode.node, false};
toNodeData->weight=to_weight; toHeapNode->weight=to_weight;
forward_heap.DecreaseKey(*toNodeData); forward_heap.DecreaseKey(*toHeapNode);
} }
} }
} }
@ -358,16 +358,16 @@ void routingStep(const DataFacade<Algorithm> &facade,
// is weight + reverse_weight // is weight + reverse_weight
// More tighter upper bound requires additional condition reverse_heap.WasRemoved(to) // More tighter upper bound requires additional condition reverse_heap.WasRemoved(to)
// with weight(to -> target) = reverse_weight and all weights ≥ 0 // with weight(to -> target) = reverse_weight and all weights ≥ 0
auto reverveNodeData= reverse_heap.GetHeapNodeIfWasInserted(heapNode.node); auto reverseNodeData = reverse_heap.GetHeapNodeIfWasInserted(heapNode.node);
if (reverveNodeData) if (reverseNodeData)
{ {
auto reverse_weight = reverveNodeData->weight; auto reverse_weight = reverseNodeData->weight;
auto path_weight = weight + reverse_weight; auto path_weight = weight + reverse_weight;
// MLD uses loops forcing only to prune single node paths in forward and/or // MLD uses loops forcing only to prune single node paths in forward and/or
// backward direction (there is no need to force loops in MLD but in CH) // backward direction (there is no need to force loops in MLD but in CH)
if (!(force_loop_forward && heapNode.data.parent == heapNode.node) && if (!(force_loop_forward && heapNode.data.parent == heapNode.node) &&
!(force_loop_reverse && reverveNodeData->data.parent == heapNode.node) && !(force_loop_reverse && reverseNodeData->data.parent == heapNode.node) &&
(path_weight >= 0) && (path_weight < path_upper_bound)) (path_weight >= 0) && (path_weight < path_upper_bound))
{ {
middle_node = heapNode.node; middle_node = heapNode.node;

View File

@ -121,7 +121,7 @@ void alternativeRoutingStep(const DataFacade<Algorithm> &facade,
forward_heap.Insert(to, to_weight, heapNode.node); forward_heap.Insert(to, to_weight, heapNode.node);
} }
// Found a shorter Path -> Update weight // Found a shorter Path -> Update weight
else if (to_weight < forward_heap.GetKey(to)) else if (to_weight < toHeapNode->weight)
{ {
// new parent // new parent
toHeapNode->data.parent = heapNode.node; toHeapNode->data.parent = heapNode.node;

View File

@ -79,7 +79,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
} }
// Found a shorter Path -> Update weight and set new parent // Found a shorter Path -> Update weight and set new parent
else if (std::tie(to_weight, to_duration) < else if (std::tie(to_weight, to_duration) <
std::tie(query_heap.GetKey(to), query_heap.GetData(to).duration)) std::tie(toHeapNode->weight, toHeapNode->data.duration))
{ {
toHeapNode->data = {heapNode.node, to_duration, to_distance}; toHeapNode->data = {heapNode.node, to_duration, to_distance};
toHeapNode->weight=to_weight; toHeapNode->weight=to_weight;

View File

@ -78,7 +78,7 @@ void relaxBorderEdges(const DataFacade<mld::Algorithm> &facade,
} }
// Found a shorter Path -> Update weight and set new parent // Found a shorter Path -> Update weight and set new parent
else if (std::tie(to_weight, to_duration, to_distance, node) < else if (std::tie(to_weight, to_duration, to_distance, node) <
std::tie(query_heap.GetKey(to), std::tie(toHeapNode->weight,
toHeapNode->data.duration, toHeapNode->data.duration,
toHeapNode->data.distance, toHeapNode->data.distance,
toHeapNode->data.parent)) toHeapNode->data.parent))
@ -140,7 +140,7 @@ void relaxOutgoingEdges(const DataFacade<mld::Algorithm> &facade,
query_heap.Insert(to, to_weight, {node, true, to_duration, to_distance}); query_heap.Insert(to, to_weight, {node, true, to_duration, to_distance});
} }
else if (std::tie(to_weight, to_duration, to_distance, node) < else if (std::tie(to_weight, to_duration, to_distance, node) <
std::tie(query_heap.GetKey(to), std::tie(toHeapNode->weight,
toHeapNode->data.duration, toHeapNode->data.duration,
toHeapNode->data.distance, toHeapNode->data.distance,
toHeapNode->data.parent)) toHeapNode->data.parent))
@ -180,7 +180,7 @@ void relaxOutgoingEdges(const DataFacade<mld::Algorithm> &facade,
query_heap.Insert(to, to_weight, {node, true, to_duration, to_distance}); query_heap.Insert(to, to_weight, {node, true, to_duration, to_distance});
} }
else if (std::tie(to_weight, to_duration, to_distance, node) < else if (std::tie(to_weight, to_duration, to_distance, node) <
std::tie(query_heap.GetKey(to), std::tie(toHeapNode->weight,
toHeapNode->data.duration, toHeapNode->data.duration,
toHeapNode->data.distance, toHeapNode->data.distance,
toHeapNode->data.parent)) toHeapNode->data.parent))