blob: b2f6811bb2e8dd8828e54970f2927092501e88f1 (
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
|
using System;
using System.Diagnostics;
using System.IO;
using Graph;
using Graph.IO;
using Interfaces;
namespace TSP
{
using Graph = Graph<double>;
using Tour = Tour<double>;
class Program
{
// https://swharden.com/CsharpDataVis/drawing/3-drawing-in-wpf.md.html
static void Main(string[] args)
{
foreach (var item in Directory.GetFiles("graphs/"))
{
Graph graph = GraphFile.Read(new FileReader(item));
// 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.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));
}
}
}
class ConsoleWriter : IFileWriter
{
public void WriteAllLines(string[] lines) =>
Array.ForEach(lines, line => Debug.WriteLine(line));
}
}
|