Merge pull request #11572 from hkhan/JAVA-8698-fix-bug-in-algorithm

[JAVA-8698] Fix minor bug in algorithm
This commit is contained in:
kwoyke 2021-12-13 08:56:19 +01:00 committed by GitHub
commit 098701a66d
1 changed files with 3 additions and 2 deletions

View File

@ -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);