diff options
author | Toby Vincent <tobyv13@gmail.com> | 2021-04-18 23:54:35 +0000 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2021-04-18 23:54:35 +0000 |
commit | cf192cef8e969c00b6d243f76e5a20b326ec59e1 (patch) | |
tree | f8930b980dd9a9e151249bc991f5cd708febdbe3 /src/CS340.TSP/Program.cs | |
parent | 57492674a247337ced3db690fdcdb965a205ed34 (diff) |
build scafolding and inital logic
Diffstat (limited to 'src/CS340.TSP/Program.cs')
-rw-r--r-- | src/CS340.TSP/Program.cs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/CS340.TSP/Program.cs b/src/CS340.TSP/Program.cs new file mode 100644 index 0000000..3dfe855 --- /dev/null +++ b/src/CS340.TSP/Program.cs @@ -0,0 +1,35 @@ +using System; +using System.IO; +using System.Linq; +using Extensions; +using Graph; +using Graph.IO; +using Interfaces; + +namespace TSP +{ + using Graph = Graph<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)); + } + } + } + + class ConsoleWriter : IFileWriter + { + public void WriteAllLines(string[] lines) => + Array.ForEach(lines, line => Console.WriteLine(line)); + } +} |