diff options
Diffstat (limited to 'src/CS340.TSP/Solve.cs')
-rw-r--r-- | src/CS340.TSP/Solve.cs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/CS340.TSP/Solve.cs b/src/CS340.TSP/Solve.cs index dd3d306..8adcd50 100644 --- a/src/CS340.TSP/Solve.cs +++ b/src/CS340.TSP/Solve.cs @@ -1,6 +1,6 @@ using System.Diagnostics; using System.Linq; -using System.Text.RegularExpressions; +using Extensions; using Graph; using Graph.IO; @@ -14,11 +14,18 @@ namespace TSP static Map Map { get; set; } static Tour BestTour = null; - public static Tour BruteForce(string file, int init) + + public static Tour MST(string file, string coords, int init) + { + Map mst = GraphFile.Read(new FileReader(file)).MST(0); + return new Tour(mst.Vertices.OrderBy(vertex => vertex.Id).ToList(), Coordinate.Parse(coords)); + } + + public static Tour BruteForce(string file, string coords, int init) { Map = GraphFile.Read(new FileReader(file)); - Tour intialTour = new Tour(Map.Vertices); - GenerateTour(intialTour[init], new Tour(Map.Vertices), new Tour()); + Tour intialTour = new Tour(Map.Vertices, Coordinate.Parse(coords)); + GenerateTour(intialTour[init], intialTour, new Tour()); return BestTour; } @@ -39,9 +46,7 @@ namespace TSP // add current City to visited if (currVisited.Cities.Count > 0) - { currCity.Parent = currVisited.Cities.Last().Id; - } currVisited.Cities.Add(currCity); |