1
1
package com .thealgorithms .graph ;
2
2
3
- import static org .junit .jupiter .api .Assertions .* ;
3
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
4
4
5
- import com .thealgorithms .graph .ConstraintShortestPath .* ;
5
+ import com .thealgorithms .graph .ConstrainedShortestPath . Graph ;
6
6
import org .junit .jupiter .api .Test ;
7
7
8
- public class ConstraintShortestPathTest {
8
+ public class ConstrainedShortestPathTest {
9
9
10
10
/**
11
11
* Tests a simple linear graph to verify if the solver calculates the shortest path correctly.
@@ -18,7 +18,7 @@ public void testSimpleGraph() {
18
18
graph .addEdge (1 , 2 , 3 , 2 );
19
19
20
20
int maxResource = 5 ;
21
- ConstraintShortestPath solver = new ConstraintShortestPath (graph , maxResource );
21
+ ConstrainedShortestPath solver = new ConstrainedShortestPath (graph , maxResource );
22
22
23
23
assertEquals (5 , solver .solve (0 , 2 ));
24
24
}
@@ -34,7 +34,7 @@ public void testNoPath() {
34
34
graph .addEdge (1 , 2 , 3 , 6 );
35
35
36
36
int maxResource = 5 ;
37
- ConstraintShortestPath solver = new ConstraintShortestPath (graph , maxResource );
37
+ ConstrainedShortestPath solver = new ConstrainedShortestPath (graph , maxResource );
38
38
39
39
assertEquals (-1 , solver .solve (0 , 2 ));
40
40
}
@@ -52,7 +52,7 @@ public void testMultiplePaths() {
52
52
graph .addEdge (2 , 3 , 3 , 2 );
53
53
54
54
int maxResource = 3 ;
55
- ConstraintShortestPath solver = new ConstraintShortestPath (graph , maxResource );
55
+ ConstrainedShortestPath solver = new ConstrainedShortestPath (graph , maxResource );
56
56
57
57
assertEquals (5 , solver .solve (0 , 3 ));
58
58
}
@@ -68,7 +68,7 @@ public void testExactResourceLimit() {
68
68
graph .addEdge (1 , 2 , 3 , 2 );
69
69
70
70
int maxResource = 5 ;
71
- ConstraintShortestPath solver = new ConstraintShortestPath (graph , maxResource );
71
+ ConstrainedShortestPath solver = new ConstrainedShortestPath (graph , maxResource );
72
72
73
73
assertEquals (5 , solver .solve (0 , 2 ));
74
74
}
@@ -84,7 +84,7 @@ public void testDisconnectedGraph() {
84
84
graph .addEdge (2 , 3 , 3 , 2 );
85
85
86
86
int maxResource = 5 ;
87
- ConstraintShortestPath solver = new ConstraintShortestPath (graph , maxResource );
87
+ ConstrainedShortestPath solver = new ConstrainedShortestPath (graph , maxResource );
88
88
89
89
assertEquals (-1 , solver .solve (0 , 3 ));
90
90
}
@@ -102,7 +102,7 @@ public void testGraphWithCycles() {
102
102
graph .addEdge (1 , 3 , 4 , 2 );
103
103
104
104
int maxResource = 3 ;
105
- ConstraintShortestPath solver = new ConstraintShortestPath (graph , maxResource );
105
+ ConstrainedShortestPath solver = new ConstrainedShortestPath (graph , maxResource );
106
106
107
107
assertEquals (6 , solver .solve (0 , 3 ));
108
108
}
@@ -120,7 +120,7 @@ public void testLargeGraphPerformance() {
120
120
}
121
121
122
122
int maxResource = 1000 ;
123
- ConstraintShortestPath solver = new ConstraintShortestPath (graph , maxResource );
123
+ ConstrainedShortestPath solver = new ConstrainedShortestPath (graph , maxResource );
124
124
125
125
assertEquals (999 , solver .solve (0 , nodeCount - 1 ));
126
126
}
@@ -136,7 +136,7 @@ public void testIsolatedNodes() {
136
136
graph .addEdge (1 , 2 , 3 , 1 );
137
137
138
138
int maxResource = 5 ;
139
- ConstraintShortestPath solver = new ConstraintShortestPath (graph , maxResource );
139
+ ConstrainedShortestPath solver = new ConstrainedShortestPath (graph , maxResource );
140
140
141
141
assertEquals (-1 , solver .solve (0 , 3 ));
142
142
}
@@ -154,7 +154,7 @@ public void testCyclicLargeGraph() {
154
154
graph .addEdge (0 , 5 , 5 , 3 );
155
155
156
156
int maxResource = 10 ;
157
- ConstraintShortestPath solver = new ConstraintShortestPath (graph , maxResource );
157
+ ConstrainedShortestPath solver = new ConstrainedShortestPath (graph , maxResource );
158
158
159
159
assertEquals (5 , solver .solve (0 , 5 ));
160
160
}
@@ -180,7 +180,7 @@ public void testLargeComplexGraph() {
180
180
graph .addEdge (8 , 9 , 2 , 1 );
181
181
182
182
int maxResource = 10 ;
183
- ConstraintShortestPath solver = new ConstraintShortestPath (graph , maxResource );
183
+ ConstrainedShortestPath solver = new ConstrainedShortestPath (graph , maxResource );
184
184
185
185
assertEquals (19 , solver .solve (0 , 9 ));
186
186
}
@@ -194,7 +194,7 @@ public void testSingleNodeGraph() {
194
194
Graph graph = new Graph (1 );
195
195
196
196
int maxResource = 0 ;
197
- ConstraintShortestPath solver = new ConstraintShortestPath (graph , maxResource );
197
+ ConstrainedShortestPath solver = new ConstrainedShortestPath (graph , maxResource );
198
198
199
199
assertEquals (0 , solver .solve (0 , 0 ));
200
200
}
@@ -211,7 +211,7 @@ public void testTightResourceConstraint() {
211
211
graph .addEdge (0 , 2 , 2 , 2 );
212
212
213
213
int maxResource = 3 ;
214
- ConstraintShortestPath solver = new ConstraintShortestPath (graph , maxResource );
214
+ ConstrainedShortestPath solver = new ConstrainedShortestPath (graph , maxResource );
215
215
216
216
assertEquals (2 , solver .solve (0 , 2 ));
217
217
}
0 commit comments