summaryrefslogtreecommitdiffstats
path: root/src/CS340.Plotter/Plot.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/CS340.Plotter/Plot.cs')
-rw-r--r--src/CS340.Plotter/Plot.cs45
1 files changed, 30 insertions, 15 deletions
diff --git a/src/CS340.Plotter/Plot.cs b/src/CS340.Plotter/Plot.cs
index 611e06f..636d955 100644
--- a/src/CS340.Plotter/Plot.cs
+++ b/src/CS340.Plotter/Plot.cs
@@ -7,35 +7,34 @@ using TSP;
namespace Plotter
{
- public partial class Plot : Form
+ public partial class PlotWindow : Form
{
// List<TourPlot[]> Plots;
List<TourPlot[]> Plots = new();
+ int CurrentGraph { get; set; } = 0;
- public Plot()
+ public PlotWindow()
{
InitializeComponent();
foreach (string graphFile in Directory.GetFiles("graphs/", "*.txt"))
- GetTours(graphFile);
+ Plots.Add(GetTourSet(graphFile));
+
+ NextGraph.Enabled = (Plots.Count > 1);
+ PrevGraph.Enabled = false;
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();
- }
+ Text = $"TSP: Graph {CurrentGraph + 1}";
+ GraphLabel.Text = $"Graph {CurrentGraph + 1}";
+ foreach (var plot in Plots[CurrentGraph])
+ plot.Render();
}
- void GetTours(string graphFile)
+ TourPlot[] GetTourSet(string graphFile)
{
string coordsFile = graphFile.Replace(".txt", ".csv");
@@ -57,19 +56,35 @@ namespace Plotter
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 });
+ return new[] { bruteForce, estimation, mst };
}
private void Canvas_SizeChanged(object sender, EventArgs e)
{
RenderWindow();
}
+
+ private void NextGraph_Click(object sender, EventArgs e)
+ {
+ CurrentGraph++;
+ RenderWindow();
+ PrevGraph.Enabled = true;
+ NextGraph.Enabled = (CurrentGraph < Plots.Count - 1);
+ }
+
+ private void PrevGraph_Click(object sender, EventArgs e)
+ {
+ CurrentGraph--;
+ RenderWindow();
+ NextGraph.Enabled = true;
+ PrevGraph.Enabled = (CurrentGraph > 0);
+ }
}
}