Merge pull request #11572 from hkhan/JAVA-8698-fix-bug-in-algorithm
[JAVA-8698] Fix minor bug in algorithm
This commit is contained in:
commit
098701a66d
|
@ -18,15 +18,16 @@ public class Travel {
|
|||
}
|
||||
|
||||
public void generateInitialTravel() {
|
||||
if (travel.isEmpty())
|
||||
if (travel.isEmpty()) {
|
||||
new Travel(10);
|
||||
}
|
||||
Collections.shuffle(travel);
|
||||
}
|
||||
|
||||
public void swapCities() {
|
||||
int a = generateRandomIndex();
|
||||
int b = generateRandomIndex();
|
||||
previousTravel = travel;
|
||||
previousTravel = new ArrayList<>(travel);
|
||||
City x = travel.get(a);
|
||||
City y = travel.get(b);
|
||||
travel.set(a, y);
|
||||
|
|
Loading…
Reference in New Issue