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