1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
using TSP;
namespace Plotter
{
public partial class Plot : Form
{
// List<TourPlot[]> Plots;
List<TourPlot[]> Plots = new();
public Plot()
{
InitializeComponent();
foreach (string graphFile in Directory.GetFiles("graphs/", "*.txt"))
GetTours(graphFile);
RenderWindow(debug: true);
}
void RenderWindow(bool debug = false)
{
foreach (var plot in Plots)
{
if (debug)
plot[0].WriteDebug();
plot[0].Render();
plot[1].Render();
plot[2].Render();
}
}
void GetTours(string graphFile)
{
string coordsFile = graphFile.Replace(".txt", ".csv");
TourPlot bruteForce = new(BruteForcePlot, BruteForceWeight, BruteForceTime);
TourPlot estimation = new(EstimationPlot, EstimatedWeight, EstimatedTime);
TourPlot mst = new(MSTPlot, MSTWeight, MSTTime);
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
bruteForce.Tour = Solve.BruteForce(graphFile, coordsFile, 0);
stopWatch.Stop();
bruteForce.RunTime = stopWatch.Elapsed;
stopWatch.Reset();
stopWatch.Start();
estimation.Tour = Solve.BruteForce(graphFile, coordsFile, 0); // TODO create estimation function
stopWatch.Stop();
estimation.RunTime = stopWatch.Elapsed;
stopWatch.Reset();
stopWatch.Start();
mst.Tour = Solve.MST(graphFile, coordsFile, 0);
stopWatch.Stop();
mst.RunTime = stopWatch.Elapsed;
Plots.Add(new[] { bruteForce, estimation, mst });
}
private void Canvas_SizeChanged(object sender, EventArgs e)
{
RenderWindow();
}
}
}
|