File tree 1 file changed +0
-61
lines changed
src/main/java/com/thealgorithms/dynamicprogramming 1 file changed +0
-61
lines changed Original file line number Diff line number Diff line change @@ -52,64 +52,3 @@ public class TSP {
52
52
}
53
53
}
54
54
}
55
- import org.junit.Test;
56
- import static org.junit.Assert.*;
57
-
58
- public class TSPTest {
59
-
60
- @Test
61
- public void testTSPWithSmallGraph() {
62
- int[][] distanceMatrix = {
63
- { 0, 10, 15, 20 },
64
- { 10, 0, 35, 25 },
65
- { 15, 35, 0, 30 },
66
- { 20, 25, 30, 0 }
67
- };
68
-
69
- TSP.initialize(distanceMatrix);
70
-
71
- int minCost = TSP.tsp(0, 1);
72
-
73
- assertEquals(80, minCost);
74
- }
75
-
76
- @Test
77
- public void testOptimalPath() {
78
- int[][] distanceMatrix = {
79
- { 0, 10, 15, 20 },
80
- { 10, 0, 35, 25 },
81
- { 15, 35, 0, 30 },
82
- { 20, 25, 30, 0 }
83
- };
84
-
85
- TSP.initialize(distanceMatrix);
86
-
87
- TSP.tsp(0, 1);
88
-
89
- String expectedPath = "0 → 1 → 3 → 2 → 0";
90
- String actualPath = TSP.printPath(0, 1);
91
-
92
- assertEquals(expectedPath, actualPath);
93
- }
94
-
95
- @Test
96
- public void testDifferentGraph() {
97
- int[][] distanceMatrix = {
98
- { 0, 29, 20, 21 },
99
- { 29, 0, 15, 17 },
100
- { 20, 15, 0, 28 },
101
- { 21, 17, 28, 0 }
102
- };
103
-
104
- TSP.initialize(distanceMatrix);
105
-
106
- int minCost = TSP.tsp(0, 1);
107
-
108
- assertEquals(75, minCost);
109
-
110
- String expectedPath = "0 → 2 → 1 → 3 → 0";
111
- String actualPath = TSP.printPath(0, 1);
112
-
113
- assertEquals(expectedPath, actualPath);
114
- }
115
- }
You can’t perform that action at this time.
0 commit comments