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