diff options
Diffstat (limited to 'src/CS340.Plotter')
-rw-r--r-- | src/CS340.Plotter/CS340.Plotter.csproj | 11 | ||||
-rw-r--r-- | src/CS340.Plotter/Plot.Designer.cs | 1 | ||||
-rw-r--r-- | src/CS340.Plotter/Plot.cs | 7 | ||||
-rw-r--r-- | src/CS340.Plotter/Program.cs | 32 | ||||
-rw-r--r-- | src/CS340.Plotter/graphs/test.txt | 6 |
5 files changed, 57 insertions, 0 deletions
diff --git a/src/CS340.Plotter/CS340.Plotter.csproj b/src/CS340.Plotter/CS340.Plotter.csproj index 7a10161..1cbf369 100644 --- a/src/CS340.Plotter/CS340.Plotter.csproj +++ b/src/CS340.Plotter/CS340.Plotter.csproj @@ -1,5 +1,16 @@ <Project Sdk="Microsoft.NET.Sdk"> + <ItemGroup> + <ProjectReference Include="..\CS340.Graph\CS340.Graph.csproj" /> + <ProjectReference Include="..\CS340.TSP\CS340.TSP.csproj" /> + <Content Include="graphs\*.*"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + </ItemGroup> + + <ItemGroup> + <None Remove="graphs\test.txt" /> + </ItemGroup> <PropertyGroup> <OutputType>WinExe</OutputType> <TargetFramework>net5.0-windows</TargetFramework> diff --git a/src/CS340.Plotter/Plot.Designer.cs b/src/CS340.Plotter/Plot.Designer.cs index 36d9a56..562d725 100644 --- a/src/CS340.Plotter/Plot.Designer.cs +++ b/src/CS340.Plotter/Plot.Designer.cs @@ -52,6 +52,7 @@ namespace Plotter this.Controls.Add(this.Canvas); this.Name = "Plot"; this.Text = "Plot"; + this.Load += new System.EventHandler(this.Plot_Load); ((System.ComponentModel.ISupportInitialize)(this.Canvas)).EndInit(); this.ResumeLayout(false); diff --git a/src/CS340.Plotter/Plot.cs b/src/CS340.Plotter/Plot.cs index f26978f..0559ece 100644 --- a/src/CS340.Plotter/Plot.cs +++ b/src/CS340.Plotter/Plot.cs @@ -32,6 +32,8 @@ namespace Plotter Canvas.Image = (Bitmap)bmp.Clone(); } + + private void Canvas_SizeChanged(object sender, EventArgs e) { Render(); @@ -41,5 +43,10 @@ namespace Plotter { Render(); } + + private void Plot_Load(object sender, EventArgs e) + { + + } } } diff --git a/src/CS340.Plotter/Program.cs b/src/CS340.Plotter/Program.cs index 0205767..497ac32 100644 --- a/src/CS340.Plotter/Program.cs +++ b/src/CS340.Plotter/Program.cs @@ -1,11 +1,17 @@ +using Graph; +using Graph.IO; using System; using System.Collections.Generic; +using System.Diagnostics; +using System.IO; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; +using TSP; namespace Plotter { + using Map = Graph<Vertex<Edge<double>, double>, Edge<double>, double>; static class Program { /// <summary> @@ -17,7 +23,33 @@ namespace Plotter Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); + Run(); Application.Run(new Plot()); } + + static void Run() + { + foreach (string file in Directory.GetFiles("graphs/")) + { + Map graph = GraphFile.Read(new FileReader(file)); + // Graph mst = graph.MST(0); + // GraphFile.Print(mst, new ConsoleWriter()); + // Console.WriteLine( + // graph.Vertices.Sum(vertex => + // vertex.Edges.FirstOrDefault(edge => edge.V == vertex.Parent).Weight)); + + Tour bruteForce = TSP.TSP.BruteForce(graph, 0); + Debug.WriteLine(bruteForce); + // mst.Vertices.ForEach(vertex => + // { + // Console.Write($"{vertex.Id}"); + // vertex.Edges.ForEach(edge => Console.Write($" {edge.V} {edge.Weight.ToString("F1")}")); + // Console.WriteLine(); + // }); + // Console.WriteLine(mst.Vertices + // .Sum(vertex => vertex.Edges + // .FirstOrDefault(edge => edge.V == vertex.Parent).Weight)); + } + } } } diff --git a/src/CS340.Plotter/graphs/test.txt b/src/CS340.Plotter/graphs/test.txt new file mode 100644 index 0000000..113fb4f --- /dev/null +++ b/src/CS340.Plotter/graphs/test.txt @@ -0,0 +1,6 @@ +0 1 78.85429601486528 2 64.62197768561404 3 59.135437767890075 4 71.84705978674423 5 54.08326913195984 +1 0 78.85429601486528 2 93.47726996441435 3 21.095023109728988 4 28.635642126552707 5 102.55242561733974 +2 0 64.62197768561404 1 93.47726996441435 3 85.23496934944014 4 67.89698078707183 5 21.840329667841555 +3 0 59.135437767890075 1 21.095023109728988 2 85.23496934944014 4 33.54101966249684 5 90.21086409075129 +4 0 71.84705978674423 1 28.635642126552707 2 67.89698078707183 3 33.54101966249684 5 80.45495634204272 +5 0 54.08326913195984 1 102.55242561733974 2 21.840329667841555 3 90.21086409075129 4 80.45495634204272
\ No newline at end of file |