feat(path): add replaceArc method

This commit is contained in:
Paul Alnet 2024-05-25 17:29:43 +02:00
parent 7cc3c39211
commit 9c47703bc4
2 changed files with 10 additions and 1 deletions

View file

@ -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 on l'a enlevé
path.getArcs().addAll(newPath.getArcs());
path.replaceArc(arcToRemove, newPath.getArcs());
}
}

View file

@ -211,6 +211,16 @@ public class Path {
return arcs;
}
/**
* Replace arc with an array of arcs
* @return
*/
public void replaceArc(Arc arc, List<Arc> 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).
*