From 231f1dbf829779de549987ea5abd4ca262387cf2 Mon Sep 17 00:00:00 2001 From: Leroy Korterink Date: Sat, 27 Oct 2018 23:52:04 +0200 Subject: [PATCH] Fix ToString method --- Graph/Graph.cs | 4 ++-- GraphTests/GraphTests.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Graph/Graph.cs b/Graph/Graph.cs index e8cbe69..b96ff65 100644 --- a/Graph/Graph.cs +++ b/Graph/Graph.cs @@ -212,10 +212,10 @@ public override string ToString() { var adjacentVertexes = vertex.AdjacentVertices.Aggregate( "", - (accumulator, edge) => { return accumulator += $"{edge.Destination.Name}({edge.Cost})"; } + (accumulator, edge) => { return accumulator += $" {edge.Destination.Name}({edge.Cost})"; } ); - output += vertex.Name + " --> " + adjacentVertexes; + output += $"{vertex.Name} -->{adjacentVertexes}\n"; } return output; diff --git a/GraphTests/GraphTests.cs b/GraphTests/GraphTests.cs index a6e7352..36c6ac8 100644 --- a/GraphTests/GraphTests.cs +++ b/GraphTests/GraphTests.cs @@ -142,7 +142,7 @@ public void Should_ToString() _output.WriteLine(myGraph.ToString()); Assert.Equal( - "V0 --> V1(2) V3(1)\nV1 --> V3(3) V4(10)\nV2 --> V0(4) V5(5)\nV3 --> V2(2) V5(8) V6(4) V4(2)\nV4 --> V6(6)\nV5 -->\nV6 --> V5(1)\n", + "V0 --> V1(2) V3(1)\nV1 --> V3(3) V4(10)\nV3 --> V2(2) V4(2) V5(8) V6(4)\nV4 --> V6(6)\nV2 --> V0(4) V5(5)\nV5 -->\nV6 --> V5(1)\n", myGraph.ToString() ); }