opti: Déplacement du BinaryHeap#deleteMin pour éviter d'itérer deux fois sur le départ

This commit is contained in:
Brendan Saint Germes 2026-05-30 14:32:53 +02:00
parent a53be0b057
commit cfb1accd01

View file

@ -42,7 +42,8 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
boolean destinationReached = false; boolean destinationReached = false;
notifyOriginProcessed(data.getOrigin()); notifyOriginProcessed(data.getOrigin());
while (!destinationReached && !this.heap.isEmpty() && currentLabel != null) { while (!destinationReached && !this.heap.isEmpty()) {
currentLabel = this.heap.deleteMin();
if (currentLabel.getTotalCost() == Double.MAX_VALUE) if (currentLabel.getTotalCost() == Double.MAX_VALUE)
break; break;
@ -81,7 +82,6 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
} }
} }
} }
currentLabel = heap.deleteMin();
} }
} }