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
+6 -4
View File
@@ -32,16 +32,18 @@ void relaxNode(ContractorHeap &heap,
}
const EdgeWeight to_weight = node_weight + data.weight;
const auto& toHeapNode=heap.WasInsertedGetHeapNode(to);
// New Node discovered -> Add to Heap + Node Info Storage
if (!heap.WasInserted(to))
if (!toHeapNode)
{
heap.Insert(to, to_weight, ContractorHeapData{current_hop, false});
}
// Found a shorter Path -> Update weight
else if (to_weight < heap.GetKey(to))
else if (to_weight < toHeapNode->weight)
{
heap.DecreaseKey(to, to_weight);
heap.GetData(to).hop = current_hop;
toHeapNode->weight=to_weight;
heap.DecreaseKey(*toHeapNode);
toHeapNode->data.hop = current_hop;
}
}
}