blob: a962057954ca31721b9d428c2347a9470b092736 (
plain)
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
|
using System;
using System.Collections.Generic;
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);
TourPlot estimation = new(EstimationPlot);
TourPlot mst = new(MSTPlot);
bruteForce.Tour = Solve.BruteForce(graphFile, coordsFile, 0);
estimation.Tour = Solve.BruteForce(graphFile, coordsFile, 0); // TODO create estimation function
mst.Tour = Solve.MST(graphFile, coordsFile, 0);
Plots.Add(new[] { bruteForce, estimation, mst });
}
private void Canvas_SizeChanged(object sender, EventArgs e)
{
RenderWindow();
}
}
}
|