refactor(marathon): getRandomArc to own function
This commit is contained in:
parent
51c2c8b29e
commit
eaa80d87fa
1 changed files with 10 additions and 4 deletions
|
@ -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())));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue