forked from lebotlan/BE-Graphes
Update Dijkstra (all notify working)
This commit is contained in:
parent
e249625793
commit
23be38ee2b
1 changed files with 4 additions and 1 deletions
|
|
@ -48,7 +48,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
while (!found && !labelsHeap.isEmpty()) {
|
while (!found && !labelsHeap.isEmpty()) {
|
||||||
concurentNodeLabel = labelsHeap.deleteMin();
|
concurentNodeLabel = labelsHeap.deleteMin();
|
||||||
if (!concurentNodeLabel.getMarque()) {
|
if (!concurentNodeLabel.getMarque()) {
|
||||||
notifyNodeReached(concurentNodeLabel.getSommetCourant());
|
notifyNodeMarked(concurentNodeLabel.getSommetCourant());
|
||||||
concurentNodeLabel.setMarque();
|
concurentNodeLabel.setMarque();
|
||||||
for (Arc arc : concurentNodeLabel.getSommetCourant().getSuccessors()) {
|
for (Arc arc : concurentNodeLabel.getSommetCourant().getSuccessors()) {
|
||||||
|
|
||||||
|
|
@ -59,6 +59,9 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
|
|
||||||
Label successorLabel = labelsList.get(arc.getDestination().getId());
|
Label successorLabel = labelsList.get(arc.getDestination().getId());
|
||||||
Double newCost = data.getCost(arc) + concurentNodeLabel.getCost();
|
Double newCost = data.getCost(arc) + concurentNodeLabel.getCost();
|
||||||
|
if (successorLabel.getCost() == Double.POSITIVE_INFINITY) {
|
||||||
|
notifyNodeReached(arc.getDestination());
|
||||||
|
}
|
||||||
if (newCost < successorLabel.getCost()) {
|
if (newCost < successorLabel.getCost()) {
|
||||||
successorLabel.setPere(arc);
|
successorLabel.setPere(arc);
|
||||||
successorLabel.setCoutRealise(newCost);
|
successorLabel.setCoutRealise(newCost);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue