Djikstra mais le chemin est cohérent

This commit is contained in:
Marie Brunetto 2023-04-05 17:12:35 +02:00
parent 24c41e7f3b
commit 6943f73f81

View file

@ -1,6 +1,8 @@
package org.insa.graphs.algorithm.shortestpath;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import org.insa.graphs.model.Node;
import org.insa.graphs.model.Arc;
import org.insa.graphs.model.Path;
@ -17,7 +19,6 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
protected ShortestPathSolution doRun() {
final ShortestPathData data = getInputData();
int tailleGraphe = data.getGraph().size();
int nbMarques = 0;
int index = 0;
ArrayList<Label> labelSommets = new ArrayList<Label>();
@ -39,7 +40,6 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
currentLabel.setMarqueTrue();
leTas.insert(currentLabel);
System.out.println("Init finie");
Node currentNode = data.getOrigin() ;
double currentCost;
@ -57,8 +57,6 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
index = currentNode.getId();
currentLabel.setMarqueTrue();
nbMarques++;
for(Arc arc : currentNode.getSuccessors())
{
@ -82,7 +80,6 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
}
}
System.out.println("Chemin obtenu");
//Retour chemin obtenu ----------------------------------------------------
@ -103,9 +100,10 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
}
if(index != tailleGraphe)
{
Collections.reverse(arcListe);
return new ShortestPathSolution(data, AbstractSolution.Status.FEASIBLE, new Path(data.getGraph(),arcListe ));
}
return new ShortestPathSolution(data, AbstractSolution.Status.INFEASIBLE);
}