refactor(marathon): getRandomArc to own function

This commit is contained in:
Paul Alnet 2024-05-25 17:41:11 +02:00
parent 51c2c8b29e
commit eaa80d87fa

View file

@ -50,7 +50,7 @@ public class MarathonAlgorithm extends ShortestPathAlgorithm {
while (path.getLength() < distanceMarathon) {
// Recuperation Arc à supprimer (cacher) et extremites
final Arc arcToRemove = getLongestArc(path);
final Arc arcToRemove = getRandomArc(path);
final Node originArcToRemove = arcToRemove.getOrigin();
final Node destinationArcToRemove = arcToRemove.getDestination();
@ -94,10 +94,16 @@ public class MarathonAlgorithm extends ShortestPathAlgorithm {
longestArc = arc;
}
}
return arcs.get(Math.abs(rand.nextInt() % (arcs.size())));
//return longestArc;
//int indiceArcToRemove = 0; //Math.abs(rand.nextInt() % (longueurPath - 1));
return longestArc;
}
private Arc getRandomArc(Path path) {
final List<Arc> arcs = path.getArcs();
if (arcs.size() == 0)
return null;
return arcs.get(Math.abs(rand.nextInt() % (arcs.size())));
}
}