diff options
Diffstat (limited to 'src/CS340.TSP/TSPSolver.cs')
-rw-r--r-- | src/CS340.TSP/TSPSolver.cs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/CS340.TSP/TSPSolver.cs b/src/CS340.TSP/TSPSolver.cs index 567c7de..159286a 100644 --- a/src/CS340.TSP/TSPSolver.cs +++ b/src/CS340.TSP/TSPSolver.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using System.Diagnostics; using System.Linq; using Extensions; @@ -74,9 +73,9 @@ namespace TSP static void BruteForce(City cityInput, Tour unvisitedInput, Tour visitedInput) { // create local copy of Tour variables - Tour unvisited = new Tour(unvisitedInput.Cities); - Tour visited = new Tour(visitedInput.Cities); - City city = new City(cityInput); + Tour unvisited = new(unvisitedInput.Cities); + Tour visited = new(visitedInput.Cities); + City city = new(cityInput); // remove current City from tour int removed = unvisited.Cities.RemoveAll(c => c.Id == city.Id); @@ -92,8 +91,8 @@ namespace TSP // add current City to visited visited.Cities.Add(city); - // loop through each city. Each level of recursion has a one less city in currTour.Cities - // leaving the base case + // loop through each city. Each level of recursion has a one less city in unvisited.Cities + // so each loop is (n - 1)! down to n == 0 as the base case foreach (City neighbor in unvisited.Cities) BruteForce(neighbor, unvisited, visited); |