forked from lebotlan/BE-Graphes
Dijkstra Updated (pour le côut et les limitations)
This commit is contained in:
parent
d53cc298d9
commit
e249625793
2 changed files with 11 additions and 6 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
package org.insa.graphs.algorithm.shortestpath;
|
package org.insa.graphs.algorithm.shortestpath;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
import org.insa.graphs.algorithm.AbstractSolution.Status;
|
import org.insa.graphs.algorithm.AbstractSolution.Status;
|
||||||
import org.insa.graphs.algorithm.utils.BinaryHeap;
|
import org.insa.graphs.algorithm.utils.BinaryHeap;
|
||||||
|
|
@ -52,8 +51,14 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
notifyNodeReached(concurentNodeLabel.getSommetCourant());
|
notifyNodeReached(concurentNodeLabel.getSommetCourant());
|
||||||
concurentNodeLabel.setMarque();
|
concurentNodeLabel.setMarque();
|
||||||
for (Arc arc : concurentNodeLabel.getSommetCourant().getSuccessors()) {
|
for (Arc arc : concurentNodeLabel.getSommetCourant().getSuccessors()) {
|
||||||
|
|
||||||
|
// Small test to check allowed roads...
|
||||||
|
if (!data.isAllowed(arc)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Label successorLabel = labelsList.get(arc.getDestination().getId());
|
Label successorLabel = labelsList.get(arc.getDestination().getId());
|
||||||
Float newCost = arc.getLength() + concurentNodeLabel.getCost();
|
Double newCost = data.getCost(arc) + concurentNodeLabel.getCost();
|
||||||
if (newCost < successorLabel.getCost()) {
|
if (newCost < successorLabel.getCost()) {
|
||||||
successorLabel.setPere(arc);
|
successorLabel.setPere(arc);
|
||||||
successorLabel.setCoutRealise(newCost);
|
successorLabel.setCoutRealise(newCost);
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,14 @@ public class Label implements Comparable<Label> {
|
||||||
|
|
||||||
private Boolean marque;
|
private Boolean marque;
|
||||||
|
|
||||||
private float coutRealise;
|
private double coutRealise;
|
||||||
|
|
||||||
private Arc pere;
|
private Arc pere;
|
||||||
|
|
||||||
public Label(Node sommetCourant) {
|
public Label(Node sommetCourant) {
|
||||||
this.sommetCourant = sommetCourant;
|
this.sommetCourant = sommetCourant;
|
||||||
this.marque = false;
|
this.marque = false;
|
||||||
this.coutRealise = Float.POSITIVE_INFINITY;
|
this.coutRealise = Double.POSITIVE_INFINITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Node getSommetCourant() {
|
public Node getSommetCourant() {
|
||||||
|
|
@ -43,11 +43,11 @@ public class Label implements Comparable<Label> {
|
||||||
// return coutRealise;
|
// return coutRealise;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public void setCoutRealise(float nouveauCout) {
|
public void setCoutRealise(double nouveauCout) {
|
||||||
this.coutRealise = nouveauCout;
|
this.coutRealise = nouveauCout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getCost() {
|
public double getCost() {
|
||||||
return coutRealise;
|
return coutRealise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue