Skip to content

Commit dcec19c

Browse files
committed
Edge cost and node item settable
1 parent e0ad6d0 commit dcec19c

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/Dijkstra.NET/Graph/Edge.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace Dijkstra.NET.Graph
55
{
6-
public readonly struct Edge<T, TCustom>: IEquatable<Edge<T, TCustom>> where TCustom: IEquatable<TCustom>
6+
public struct Edge<T, TCustom>: IEquatable<Edge<T, TCustom>> where TCustom: IEquatable<TCustom>
77
{
88
public Edge(INode<T, TCustom> node, int cost, TCustom custom)
99
{
@@ -14,7 +14,7 @@ public Edge(INode<T, TCustom> node, int cost, TCustom custom)
1414

1515
public INode<T, TCustom> Node { get; }
1616

17-
public int Cost { get; }
17+
public int Cost { get; set; }
1818

1919
public TCustom Item { get; }
2020

@@ -42,5 +42,9 @@ public override bool Equals(object obj)
4242
return Equals(other.Value);
4343
}
4444

45+
public void SetCost(int cost)
46+
{
47+
Cost = cost;
48+
}
4549
}
4650
}

src/Dijkstra.NET/Graph/INode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ public interface INode
1010

1111
public interface INode<T, TEdgeCustom> : INode, IEnumerable<Edge<T, TEdgeCustom>> where TEdgeCustom : IEquatable<TEdgeCustom>
1212
{
13-
T Item { get; }
13+
T Item { get; set; }
1414
}
1515
}

src/Dijkstra.NET/Graph/Node.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static EdgeTemp<T, TEdgeCustom> operator>>(Node<T, TEdgeCustom> nodeFrom,
3232

3333
public uint Key { get; }
3434

35-
public T Item { get; }
35+
public T Item { get; set; }
3636

3737
public int EdgesCount { get; internal set; }
3838

0 commit comments

Comments
 (0)