11using Advanced . Algorithms . DataStructures ;
22using Advanced . Algorithms . DataStructures . Graph ;
3- using Advanced . Algorithms . DataStructures . Graph . AdjacencyList ;
43using System ;
54using System . Collections . Generic ;
65using System . Linq ;
@@ -21,7 +20,7 @@ public DijikstraShortestPath(IShortestPathOperators<W> @operator)
2120 /// <summary>
2221 /// Get shortest distance to target.
2322 /// </summary>
24- public ShortestPathResult < T , W > FindShortestPath ( IDiGraph < T > graph , T source , T destination )
23+ public ShortestPathResult < T , W > FindShortestPath ( IGraph < T > graph , T source , T destination )
2524 {
2625 //regular argument checks
2726 if ( graph ? . GetVertex ( source ) == null || graph . GetVertex ( destination ) == null )
@@ -93,11 +92,11 @@ public ShortestPathResult<T, W> FindShortestPath(IDiGraph<T> graph, T source, T
9392 }
9493
9594 //visit neighbours of current
96- foreach ( var neighbour in graph . GetVertex ( current . Vertex ) . OutEdges . Where ( x => ! x . TargetVertexKey . Equals ( source ) ) )
95+ foreach ( var neighbour in graph . GetVertex ( current . Vertex ) . Edges . Where ( x => ! x . TargetVertexKey . Equals ( source ) ) )
9796 {
9897 //new distance to neighbour
9998 var newDistance = @operator . Sum ( current . Distance ,
100- graph . GetVertex ( current . Vertex ) . GetOutEdge ( neighbour . TargetVertex ) . Weight < W > ( ) ) ;
99+ graph . GetVertex ( current . Vertex ) . GetEdge ( neighbour . TargetVertex ) . Weight < W > ( ) ) ;
101100
102101 //current distance to neighbour
103102 var existingDistance = progress [ neighbour . TargetVertexKey ] ;
@@ -135,7 +134,7 @@ public ShortestPathResult<T, W> FindShortestPath(IDiGraph<T> graph, T source, T
135134 /// <summary>
136135 /// Trace back path from destination to source using parent map.
137136 /// </summary>
138- private ShortestPathResult < T , W > tracePath ( IDiGraph < T > graph , Dictionary < T , T > parentMap , T source , T destination )
137+ private ShortestPathResult < T , W > tracePath ( IGraph < T > graph , Dictionary < T , T > parentMap , T source , T destination )
139138 {
140139 //trace the path
141140 var pathStack = new Stack < T > ( ) ;
@@ -160,7 +159,7 @@ private ShortestPathResult<T, W> tracePath(IDiGraph<T> graph, Dictionary<T, T> p
160159 for ( int i = 0 ; i < resultPath . Count - 1 ; i ++ )
161160 {
162161 resultLength = @operator . Sum ( resultLength ,
163- graph . GetVertex ( resultPath [ i ] ) . GetOutEdge ( graph . GetVertex ( resultPath [ i + 1 ] ) ) . Weight < W > ( ) ) ;
162+ graph . GetVertex ( resultPath [ i ] ) . GetEdge ( graph . GetVertex ( resultPath [ i + 1 ] ) ) . Weight < W > ( ) ) ;
164163 }
165164
166165 return new ShortestPathResult < T , W > ( resultPath , resultLength ) ;
0 commit comments