Version Dijkstra corrigée (pas testée)

This commit is contained in:
Marie Brunetto 2023-04-05 15:32:46 +02:00
parent a0bcb97341
commit aff74a7bad

View file

@ -40,6 +40,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
Node currentNode; Node currentNode;
double currentCost; double currentCost;
double newCost; double newCost;
Label newLabel;
while (nbMarques != tailleGraphe) while (nbMarques != tailleGraphe)
@ -55,14 +56,14 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
for(Arc arc : currentNode.getSuccessors()) for(Arc arc : currentNode.getSuccessors())
{ {
currentLabel = labelSommets.get(arc.getDestination().getId()); newLabel = labelSommets.get(arc.getDestination().getId());
if(!currentLabel.getMarque()) if(!newLabel.getMarque())
{ {
currentCost = currentLabel.getCost(); currentCost = newLabel.getCost() + currentLabel.getCost();
newCost = arc.getLength(); newCost = arc.getLength();
if(newCost < currentCost || currentCost == -1.0) if(newCost < currentCost || currentCost == -1.0)
{ {
currentLabel.setNouveauChemin(arc, newCost); newLabel.setNouveauChemin(arc, newCost);
leTas.insert(arc.getDestination()); leTas.insert(arc.getDestination());
labelSommets.set(arc.getDestination().getId(), currentLabel); labelSommets.set(arc.getDestination().getId(), currentLabel);
} }