1
0
Fork 0

DONE Dijsktra

This commit is contained in:
Sebastien Moll 2026-04-20 06:50:49 +02:00
parent fa87e8d63b
commit d53cc298d9

View file

@ -39,7 +39,6 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
Label destinationNodeLabel = labelsList.get(data.getDestination().getId()); Label destinationNodeLabel = labelsList.get(data.getDestination().getId());
Label concurentNodeLabel = labelsList.get(data.getOrigin().getId()); Label concurentNodeLabel = labelsList.get(data.getOrigin().getId());
concurentNodeLabel.setCoutRealise(0); concurentNodeLabel.setCoutRealise(0);
concurentNodeLabel.setMarque();
notifyOriginProcessed(data.getOrigin()); notifyOriginProcessed(data.getOrigin());
@ -72,11 +71,11 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
ArrayList<Arc> pathArcs = new ArrayList<Arc>(); ArrayList<Arc> pathArcs = new ArrayList<Arc>();
concurentNodeLabel = destinationNodeLabel; concurentNodeLabel = destinationNodeLabel;
while(concurentNodeLabel.getPere() != null) { while(concurentNodeLabel.getPere() != null) {
pathArcs.add(concurentNodeLabel.getPere()); pathArcs.add(0, concurentNodeLabel.getPere());
concurentNodeLabel = labelsList.get(concurentNodeLabel.getPere().getOrigin().getId()); concurentNodeLabel = labelsList.get(concurentNodeLabel.getPere().getOrigin().getId());
} }
Collections.reverse(pathArcs); // Collections.reverse(pathArcs);
solution = new ShortestPathSolution(data, Status.OPTIMAL, new Path(graph, pathArcs)); solution = new ShortestPathSolution(data, Status.OPTIMAL, new Path(graph, pathArcs));