Skip to content

Commit ea929cc

Browse files
committed
polish immutable solution
1 parent f880651 commit ea929cc

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

src/Dijkstra.NET/Extensions/ShortestPathExtensions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ namespace Dijkstra.NET.Extensions
88
{
99
public static class ShortestPathExtensions
1010
{
11+
/// <summary>
12+
/// Get path from @from to @to
13+
/// </summary>
14+
/// <param name="graph">Source graph</param>
15+
/// <param name="from">Start node</param>
16+
/// <param name="to">End node</param>
17+
/// <returns>Value with path</returns>
1118
public static ShortestPathResult Dijkstra<T, TEdgeCustom>(this IGraph<T, TEdgeCustom> graph, uint from, uint to)
1219
where TEdgeCustom : IEquatable<TEdgeCustom>
1320
{

src/Dijkstra.NET/Model/Graph.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,10 @@ public Graph<T, TEdgeCustom> Clone()
6767
foreach (var node in _nodes.Values)
6868
graph.AddNode(node.Key, node.Item);
6969

70-
//todo
71-
// foreach (var node in _nodes.Values.Where(x => x.Children.Count > 0))
72-
// {
73-
// foreach (var edge in node.Children)
74-
// graph.Connect(node.Key, edge.Node.Key, edge.Cost, edge.Item);
75-
// }
70+
foreach (var node in _nodes.Values.Where(x => x.ChildrenCount > 0))
71+
{
72+
node.EachChild((in Edge<T, TEdgeCustom> edge) => graph.Connect(node.Key, edge.Node.Key, edge.Cost, edge.Item));
73+
}
7674

7775
return graph;
7876
}

src/Dijkstra.NET/Model/Node.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ internal void AddChild(in Edge<T, TEdgeCustom> edge)
4040
newSize = bigSize < Int32.MaxValue ? (int)bigSize : Int32.MaxValue;
4141
}
4242

43-
4443
Array.Resize(ref _children, newSize);
4544
}
4645

src/Dijkstra.NET/ShortestPath/BfsParallel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Dijkstra.NET.ShortestPath
1111
/// </summary>
1212
/// <typeparam name="T"></typeparam>
1313
/// <typeparam name="TEdgeCustom"></typeparam>
14-
[Obsolete]
14+
[Obsolete("BFS paraller version will not be supported any more and removed in next release.")]
1515
public class BfsParallel<T, TEdgeCustom> : Dijkstra<T, TEdgeCustom> where TEdgeCustom : IEquatable<TEdgeCustom>
1616
{
1717
private readonly ProducerConsumer<T, TEdgeCustom> _table;

src/Dijkstra.NET/ShortestPath/Model/ShortPathJob.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
namespace Dijkstra.NET.ShortestPath.Model
1+
using System;
2+
3+
namespace Dijkstra.NET.ShortestPath.Model
24
{
5+
[Obsolete]
36
public struct ShortPathJob
47
{
58
public uint NodeKey { get; set; }

0 commit comments

Comments
 (0)