diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/marathon/MarathonAlgorithm.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/marathon/MarathonAlgorithm.java index f92ed7b..77985e5 100644 --- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/marathon/MarathonAlgorithm.java +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/marathon/MarathonAlgorithm.java @@ -63,7 +63,6 @@ public class MarathonAlgorithm extends ShortestPathAlgorithm { // could get stuck in a loop if no path is found, given the current arcToRemove strategy if (newPath != null) { // Ajout du path trouvé à l'indice où on l'a enlevé - path.getArcs().addAll(newPath.getArcs()); path.replaceArc(arcToRemove, newPath.getArcs()); } } diff --git a/be-graphes-model/src/main/java/org/insa/graphs/model/Path.java b/be-graphes-model/src/main/java/org/insa/graphs/model/Path.java index c791286..f3fabee 100644 --- a/be-graphes-model/src/main/java/org/insa/graphs/model/Path.java +++ b/be-graphes-model/src/main/java/org/insa/graphs/model/Path.java @@ -211,6 +211,16 @@ public class Path { return arcs; } + /** + * Replace arc with an array of arcs + * @return + */ + public void replaceArc(Arc arc, List newArcs) { + final int index = this.arcs.indexOf(arc); + this.arcs.remove(index); + this.arcs.addAll(index, newArcs); + } + /** * Check if this path is empty (it does not contain any node). *