opti: Déplacement du BinaryHeap#deleteMin pour éviter d'itérer deux fois sur le départ
This commit is contained in:
parent
a53be0b057
commit
cfb1accd01
1 changed files with 2 additions and 2 deletions
|
|
@ -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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue