1
1
using System . Linq ;
2
2
using Dijkstra . NET . Graph ;
3
+ using Dijkstra . NET . Graph . Simple ;
3
4
using Dijkstra . NET . ShortestPath ;
4
5
using Xunit ;
5
6
@@ -31,6 +32,40 @@ public void DijkstraGraphShould_Find_Path_In_Multi_Paths_Graph()
31
32
Assert . True ( result . IsFounded ) ;
32
33
}
33
34
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
+
34
69
[ Fact ]
35
70
public void DijkstraGraphShould_Find_Path_In_Override_Node ( )
36
71
{
@@ -109,6 +144,19 @@ public void DijkstraGraphShould_Find_Path_With_One_Vertex_In_Graph()
109
144
Assert . True ( result . IsFounded ) ;
110
145
}
111
146
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
+
112
160
[ Fact ]
113
161
public void DijkstraGraphShould_Find_Path_With_One_Vertex_In_Graph_And_Depth_Zero ( )
114
162
{
@@ -123,6 +171,19 @@ public void DijkstraGraphShould_Find_Path_With_One_Vertex_In_Graph_And_Depth_Zer
123
171
Assert . True ( result . IsFounded ) ;
124
172
}
125
173
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
+
126
187
[ Fact ]
127
188
public void DijkstraGraphShould_Find_Path_With_One_Vertex_And_One_Edge_In_Graph ( )
128
189
{
@@ -139,6 +200,21 @@ public void DijkstraGraphShould_Find_Path_With_One_Vertex_And_One_Edge_In_Graph(
139
200
Assert . True ( result . IsFounded ) ;
140
201
}
141
202
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
+
142
218
[ Fact ]
143
219
public void DijkstraGraphShould_Find_Path_In_Multi_Edges_Graph ( )
144
220
{
@@ -173,7 +249,7 @@ public void DijkstraGraphShould_Find_Path_In_Multi_Edges_Graph()
173
249
}
174
250
175
251
[ Fact ]
176
- public void DijkstraGraphShould_Find_Path_In_Multi_Edges_SimpleGraph ( )
252
+ public void DijkstraSimpleGraphShould_Find_Path_In_Multi_Edges ( )
177
253
{
178
254
var graph = new Graph . Simple . Graph ( ) ;
179
255
@@ -229,7 +305,7 @@ public void DijkstraGraphNot_Should_Find_Path_In_Graph()
229
305
}
230
306
231
307
[ Fact ]
232
- public void DijkstraGraphNot_Should_Find_Path_In_SimpleGraph ( )
308
+ public void DijkstraSimpleGraphNot_Should_Find_Path_In_Graph ( )
233
309
{
234
310
var graph = new Graph . Simple . Graph ( ) ;
235
311
0 commit comments