11using System . Linq ;
22using Dijkstra . NET . Graph ;
3+ using Dijkstra . NET . Graph . Simple ;
34using Dijkstra . NET . ShortestPath ;
45using Xunit ;
56
@@ -31,6 +32,40 @@ public void DijkstraGraphShould_Find_Path_In_Multi_Paths_Graph()
3132 Assert . True ( result . IsFounded ) ;
3233 }
3334
35+ [ Fact ]
36+ public void DijkstraSimpleGraphShould_Find_Path_In_Multi_Paths_Graph ( )
37+ {
38+ var graph = new Graph . Simple . Graph ( ) + 6 ;
39+
40+ var connected = graph >> 1 >> 2 ^ 2 ;
41+ Assert . True ( connected ) ;
42+ connected = graph >> 1 >> 3 ^ 3 ;
43+ Assert . True ( connected ) ;
44+
45+ connected = graph >> 2 >> 4 ^ 4 ;
46+ Assert . True ( connected ) ;
47+
48+ connected = graph >> 3 >> 4 ^ 2 ;
49+ Assert . True ( connected ) ;
50+
51+ connected = graph >> 3 >> 5 ^ 1 ;
52+ Assert . True ( connected ) ;
53+
54+ connected = graph >> 4 >> 6 ^ 6 ;
55+ Assert . True ( connected ) ;
56+
57+ var result = graph . Dijkstra ( 1 , 6 ) ;
58+ uint [ ] path = result . GetPath ( ) . ToArray ( ) ;
59+
60+ Assert . Equal < uint > ( 1 , path [ 0 ] ) ;
61+ Assert . Equal < uint > ( 3 , path [ 1 ] ) ;
62+ Assert . Equal < uint > ( 4 , path [ 2 ] ) ;
63+ Assert . Equal < uint > ( 6 , path [ 3 ] ) ;
64+
65+ Assert . Equal ( 11 , result . Distance ) ;
66+ Assert . True ( result . IsFounded ) ;
67+ }
68+
3469 [ Fact ]
3570 public void DijkstraGraphShould_Find_Path_In_Override_Node ( )
3671 {
@@ -109,6 +144,19 @@ public void DijkstraGraphShould_Find_Path_With_One_Vertex_In_Graph()
109144 Assert . True ( result . IsFounded ) ;
110145 }
111146
147+ [ Fact ]
148+ public void DijkstraSimpleGraphShould_Find_Path_With_One_Vertex_In_Graph ( )
149+ {
150+ var graph = 1 . ToGraph ( ) ;
151+
152+ var result = graph . Dijkstra ( 1 , 1 ) ;
153+ uint [ ] path = result . GetPath ( ) . ToArray ( ) ;
154+
155+ Assert . Equal < uint > ( 1 , path [ 0 ] ) ;
156+ Assert . Equal ( 0 , result . Distance ) ;
157+ Assert . True ( result . IsFounded ) ;
158+ }
159+
112160 [ Fact ]
113161 public void DijkstraGraphShould_Find_Path_With_One_Vertex_In_Graph_And_Depth_Zero ( )
114162 {
@@ -123,6 +171,19 @@ public void DijkstraGraphShould_Find_Path_With_One_Vertex_In_Graph_And_Depth_Zer
123171 Assert . True ( result . IsFounded ) ;
124172 }
125173
174+ [ Fact ]
175+ public void DijkstraSimpleGraphShould_Find_Path_With_One_Vertex_In_Graph_And_Depth_Zero ( )
176+ {
177+ var graph = 1 . ToGraph ( ) ;
178+
179+ var result = graph . Dijkstra ( 1 , 1 , 0 ) ;
180+ uint [ ] path = result . GetPath ( ) . ToArray ( ) ;
181+
182+ Assert . Equal < uint > ( 1 , path [ 0 ] ) ;
183+ Assert . Equal ( 0 , result . Distance ) ;
184+ Assert . True ( result . IsFounded ) ;
185+ }
186+
126187 [ Fact ]
127188 public void DijkstraGraphShould_Find_Path_With_One_Vertex_And_One_Edge_In_Graph ( )
128189 {
@@ -139,6 +200,21 @@ public void DijkstraGraphShould_Find_Path_With_One_Vertex_And_One_Edge_In_Graph(
139200 Assert . True ( result . IsFounded ) ;
140201 }
141202
203+ [ Fact ]
204+ public void DijkstraSimpleGraphShould_Find_Path_With_One_Vertex_And_One_Edge_In_Graph ( )
205+ {
206+ var graph = 1 . ToGraph ( ) ;
207+
208+ graph . Connect ( 1 , 1 , 5 ) ;
209+
210+ var result = graph . Dijkstra ( 1 , 1 ) ;
211+ uint [ ] path = result . GetPath ( ) . ToArray ( ) ;
212+
213+ Assert . Equal < uint > ( 1 , path [ 0 ] ) ;
214+ Assert . Equal ( 0 , result . Distance ) ;
215+ Assert . True ( result . IsFounded ) ;
216+ }
217+
142218 [ Fact ]
143219 public void DijkstraGraphShould_Find_Path_In_Multi_Edges_Graph ( )
144220 {
@@ -173,7 +249,7 @@ public void DijkstraGraphShould_Find_Path_In_Multi_Edges_Graph()
173249 }
174250
175251 [ Fact ]
176- public void DijkstraGraphShould_Find_Path_In_Multi_Edges_SimpleGraph ( )
252+ public void DijkstraSimpleGraphShould_Find_Path_In_Multi_Edges ( )
177253 {
178254 var graph = new Graph . Simple . Graph ( ) ;
179255
@@ -229,7 +305,7 @@ public void DijkstraGraphNot_Should_Find_Path_In_Graph()
229305 }
230306
231307 [ Fact ]
232- public void DijkstraGraphNot_Should_Find_Path_In_SimpleGraph ( )
308+ public void DijkstraSimpleGraphNot_Should_Find_Path_In_Graph ( )
233309 {
234310 var graph = new Graph . Simple . Graph ( ) ;
235311
0 commit comments