Skip to content

Commit 2d2175d

Browse files
committed
issue-19 refactor
1 parent 6e777ad commit 2d2175d

File tree

4 files changed

+8
-33
lines changed

4 files changed

+8
-33
lines changed

src/Dijkstra.NET.Tests/Dijkstra.NET.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>netcoreapp2.0</TargetFramework>

src/Dijkstra.NET.Tests/Extensions/ShortestPathExtensionsTests.cs renamed to src/Dijkstra.NET.Tests/ShortestPath/DijkstraExtensionsTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
using Dijkstra.NET.ShortestPath;
44
using Xunit;
55

6-
namespace Dijkstra.NET.Tests.Extensions
6+
namespace Dijkstra.NET.Tests.ShortestPath
77
{
8-
public class ShortestPathExtensionsTests
8+
public class DijkstraExtensionsTests
99
{
1010
[Fact]
1111
public void DijkstraGraphShould_Find_Path_In_Multi_Paths_Graph()

src/Dijkstra.NET/ShortestPath/DijkstraExtensions.cs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -31,35 +31,5 @@ public static ShortestPathResult Dijkstra<T, TEdgeCustom>(this IGraph<T, TEdgeCu
3131
{
3232
return ShortestPath.Dijkstra.GetShortestPath(graph, from, to, depth);
3333
}
34-
35-
/// <summary>
36-
/// Get path from @from to @to
37-
/// </summary>
38-
/// <param name="graph">Source graph</param>
39-
/// <param name="from">Start node</param>
40-
/// <param name="to">End node</param>
41-
/// <returns>Value with path</returns>
42-
public static ShortestPathResult DijkstraBinary<T, TEdgeCustom>(this IGraph<T, TEdgeCustom> graph, uint from, uint to)
43-
where TEdgeCustom : IEquatable<TEdgeCustom> => DijkstraBinary(graph, from, to, Int32.MaxValue);
44-
45-
/// <summary>
46-
/// Get path from @from to @to
47-
/// </summary>
48-
/// <param name="graph">Source graph</param>
49-
/// <param name="from">Start node</param>
50-
/// <param name="to">End node</param>
51-
/// <param name="depth">Depth of path</param>
52-
/// <returns>Value with path</returns>
53-
public static ShortestPathResult DijkstraBinary<T, TEdgeCustom>(this IGraph<T, TEdgeCustom> graph, uint from, uint to,
54-
int depth)
55-
where TEdgeCustom : IEquatable<TEdgeCustom>
56-
{
57-
var p1 = Task.Factory.StartNew(() => ShortestPath.Dijkstra.GetShortestPath(graph, from, to, depth, 2, 0));
58-
var p2 = Task.Factory.StartNew(() => ShortestPath.Dijkstra.GetShortestPath(graph, from, to, depth, 2, 1));
59-
60-
Task.WaitAll(p1, p2);
61-
62-
return p1.Result.Distance < p2.Result.Distance ? p1.Result : p2.Result;
63-
}
6434
}
6535
}

src/Dijkstra.NET/ShortestPath/ShortestPathResult.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,10 @@ public IEnumerable<uint> GetReversePath()
4747
}
4848

4949
public IEnumerable<uint> GetPath() => GetReversePath().Reverse();
50+
51+
public override string ToString()
52+
{
53+
return $"({FromNode})-[{Distance}]->({ToNode})";
54+
}
5055
}
5156
}

0 commit comments

Comments
 (0)