From cfb1accd01c3d47080c00483bbf9633145fde2e2 Mon Sep 17 00:00:00 2001 From: Brendan Saint-Germes Date: Sat, 30 May 2026 14:32:53 +0200 Subject: [PATCH] =?UTF-8?q?opti:=20D=C3=A9placement=20du=20BinaryHeap#dele?= =?UTF-8?q?teMin=20pour=20=C3=A9viter=20d'it=C3=A9rer=20deux=20fois=20sur?= =?UTF-8?q?=20le=20d=C3=A9part?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java index 6f13a93..2c09554 100644 --- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java @@ -42,7 +42,8 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm { boolean destinationReached = false; 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) break; @@ -81,7 +82,6 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm { } } } - currentLabel = heap.deleteMin(); } }