1
1
package com .thealgorithms .datastructures .graphs ;
2
2
3
- import org .junit .jupiter .api .BeforeEach ;
4
- import org .junit .jupiter .api .Test ;
5
-
6
3
import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
7
4
import static org .junit .jupiter .api .Assertions .assertThrows ;
8
5
6
+ import org .junit .jupiter .api .BeforeEach ;
7
+ import org .junit .jupiter .api .Test ;
8
+
9
9
public class DijkstraAlgorithmTest {
10
10
11
11
private DijkstraAlgorithm dijkstraAlgorithm ;
@@ -14,15 +14,15 @@ public class DijkstraAlgorithmTest {
14
14
@ BeforeEach
15
15
void setUp () {
16
16
graph = new int [][] {
17
- {0 , 4 , 0 , 0 , 0 , 0 , 0 , 8 , 0 },
18
- {4 , 0 , 8 , 0 , 0 , 0 , 0 , 11 , 0 },
19
- {0 , 8 , 0 , 7 , 0 , 4 , 0 , 0 , 2 },
20
- {0 , 0 , 7 , 0 , 9 , 14 , 0 , 0 , 0 },
21
- {0 , 0 , 0 , 9 , 0 , 10 , 0 , 0 , 0 },
22
- {0 , 0 , 4 , 14 , 10 , 0 , 2 , 0 , 0 },
23
- {0 , 0 , 0 , 0 , 0 , 2 , 0 , 1 , 6 },
24
- {8 , 11 , 0 , 0 , 0 , 0 , 1 , 0 , 7 },
25
- {0 , 0 , 2 , 0 , 0 , 0 , 6 , 7 , 0 },
17
+ {0 , 4 , 0 , 0 , 0 , 0 , 0 , 8 , 0 },
18
+ {4 , 0 , 8 , 0 , 0 , 0 , 0 , 11 , 0 },
19
+ {0 , 8 , 0 , 7 , 0 , 4 , 0 , 0 , 2 },
20
+ {0 , 0 , 7 , 0 , 9 , 14 , 0 , 0 , 0 },
21
+ {0 , 0 , 0 , 9 , 0 , 10 , 0 , 0 , 0 },
22
+ {0 , 0 , 4 , 14 , 10 , 0 , 2 , 0 , 0 },
23
+ {0 , 0 , 0 , 0 , 0 , 2 , 0 , 1 , 6 },
24
+ {8 , 11 , 0 , 0 , 0 , 0 , 1 , 0 , 7 },
25
+ {0 , 0 , 2 , 0 , 0 , 0 , 6 , 7 , 0 },
26
26
};
27
27
28
28
dijkstraAlgorithm = new DijkstraAlgorithm (graph .length );
@@ -37,10 +37,7 @@ void testRunAlgorithm() {
37
37
@ Test
38
38
void testGraphWithDisconnectedNodes () {
39
39
int [][] disconnectedGraph = {
40
- {0 , 3 , 0 , 0 },
41
- {3 , 0 , 1 , 0 },
42
- {0 , 1 , 0 , 0 },
43
- {0 , 0 , 0 , 0 } // Node 3 is disconnected
40
+ {0 , 3 , 0 , 0 }, {3 , 0 , 1 , 0 }, {0 , 1 , 0 , 0 }, {0 , 0 , 0 , 0 } // Node 3 is disconnected
44
41
};
45
42
46
43
DijkstraAlgorithm dijkstraDisconnected = new DijkstraAlgorithm (disconnectedGraph .length );
0 commit comments