diff options
author | Toby Vincent <tobyv13@gmail.com> | 2021-03-27 19:02:02 +0000 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2021-03-27 19:02:14 +0000 |
commit | 58f0850f0df9e02ef50a147f3ebe1a8711318a35 (patch) | |
tree | 0bfe69fa1c8e506e8e09aae9476fff41567b6ad0 /IO | |
parent | 1c2b72905bb59c911ddbbb99075eaa19f601decb (diff) |
more work
Diffstat (limited to 'IO')
-rw-r--r-- | IO/GraphFile.cs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/IO/GraphFile.cs b/IO/GraphFile.cs index 9298e4b..a532681 100644 --- a/IO/GraphFile.cs +++ b/IO/GraphFile.cs @@ -1,3 +1,4 @@ +using System.Linq; using System.Text.RegularExpressions; using Graph.Interfaces; @@ -43,12 +44,23 @@ namespace Graph.IO public static void Print(Graph<double> graph, IFileWriter writer) { string outstring = ""; - graph.Vertices.ForEach(v => + graph.Vertices.ForEach(vertex => { - outstring += $"\n{v.Id}"; - v.Edges.ForEach(e => outstring += $" {e.V} {e.Weight.ToString("F1")}"); + outstring += $"\n{vertex.Id}"; + + vertex.Edges.ForEach(edge => { + var vertex = graph.Vertices.Find(v => v.Id == edge.V); + if (vertex != null && vertex.Parent == vertex.Id) + outstring += $" {edge.V} {edge.Weight.ToString("F1")}"; + }); }); writer.WriteAllText(outstring.Trim()); } } -}
\ No newline at end of file +} + +// var neighbors = graph.Vertices +// .Where(u => u.Parent == vertex.Id && vertex.Edges.Exists(e => e.V == u.Id)); + +// var edges = vertex.Edges +// .Where(e => graph.Vertices.Find(v => v.Id == e.V).Parent == vertex.Id);
\ No newline at end of file |