refactor(marathon): rename solution to more coherent naming schema

This commit is contained in:
Paul Alnet 2024-05-25 15:25:51 +02:00
parent 63da86ab0f
commit de340c65dd

View file

@ -41,20 +41,20 @@ public class MarathonAlgorithm extends ShortestPathAlgorithm {
final ShortestPathData data = getInputData();
final Graph graph = data.getGraph();
DijkstraAlgorithm dijkstra = new DijkstraAlgorithm(data);
ShortestPathSolution path = dijkstra.run();
final ShortestPathSolution solution = (new DijkstraAlgorithm(data)).run();
final Path path = solution.getPath();
if (!path.isFeasible())
return path;
if (!solution.isFeasible())
return solution;
while (path.getPath().getLength() < getDistance()) {
while (path.getLength() < getDistance()) {
// Recuperation Arc à supprimer
Arc arcToRemove = getLongestArc(path.getPath());
Arc arcToRemove = getLongestArc(path);
Node originArcToRemove = arcToRemove.getOrigin();
Node destinationArcToRemove = arcToRemove.getDestination();
// On le supprime dans une copie du tableau (getter Collections.unmodifiable dans Path.java)
path.getPath().getArcs().remove(arcToRemove);
path.getArcs().remove(arcToRemove);
originArcToRemove.removeArc(arcToRemove);
// Creations du chemin entre les 2 noeuds dont l'arc a été supprimé
@ -65,11 +65,11 @@ public class MarathonAlgorithm extends ShortestPathAlgorithm {
if (newPath.getPath() != null) {
// Ajout du path trouvé à l'indice on l'a enlevé
path.getPath().getArcs().addAll(newPath.getPath().getArcs());
path.getArcs().addAll(newPath.getPath().getArcs());
}
}
return path;
return solution;
}