1
0
Fork 0

Dijkstra Updated (pour le côut et les limitations)

This commit is contained in:
Sebastien Moll 2026-05-06 16:20:23 +02:00
parent d53cc298d9
commit e249625793
2 changed files with 11 additions and 6 deletions

View file

@ -1,7 +1,6 @@
package org.insa.graphs.algorithm.shortestpath;
import java.util.ArrayList;
import java.util.Collections;
import org.insa.graphs.algorithm.AbstractSolution.Status;
import org.insa.graphs.algorithm.utils.BinaryHeap;
@ -52,8 +51,14 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
notifyNodeReached(concurentNodeLabel.getSommetCourant());
concurentNodeLabel.setMarque();
for (Arc arc : concurentNodeLabel.getSommetCourant().getSuccessors()) {
// Small test to check allowed roads...
if (!data.isAllowed(arc)) {
continue;
}
Label successorLabel = labelsList.get(arc.getDestination().getId());
Float newCost = arc.getLength() + concurentNodeLabel.getCost();
Double newCost = data.getCost(arc) + concurentNodeLabel.getCost();
if (newCost < successorLabel.getCost()) {
successorLabel.setPere(arc);
successorLabel.setCoutRealise(newCost);

View file

@ -9,14 +9,14 @@ public class Label implements Comparable<Label> {
private Boolean marque;
private float coutRealise;
private double coutRealise;
private Arc pere;
public Label(Node sommetCourant) {
this.sommetCourant = sommetCourant;
this.marque = false;
this.coutRealise = Float.POSITIVE_INFINITY;
this.coutRealise = Double.POSITIVE_INFINITY;
}
public Node getSommetCourant() {
@ -43,11 +43,11 @@ public class Label implements Comparable<Label> {
// return coutRealise;
// }
public void setCoutRealise(float nouveauCout) {
public void setCoutRealise(double nouveauCout) {
this.coutRealise = nouveauCout;
}
public float getCost() {
public double getCost() {
return coutRealise;
}