Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 21.3k
Expand file tree
/
Copy pathAllPathsFromSourceToTargetTest.java
More file actions
Latest commit
57 lines (50 loc) · 2.23 KB
/
Copy pathAllPathsFromSourceToTargetTest.java
File metadata and controls
57 lines (50 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
packagecom.thealgorithms.backtracking;
importstaticorg.junit.jupiter.api.Assertions.assertIterableEquals;
importjava.util.List;
importorg.junit.jupiter.api.Test;
publicclassAllPathsFromSourceToTargetTest {
@Test
voidtestForFirstCase() {
intvertices = 4;
int[][] a = {{0, 1}, {0, 2}, {0, 3}, {2, 0}, {2, 1}, {1, 3}};
intsource = 2;
intdestination = 3;
List<List<Integer>> list2 = List.of(List.of(2, 0, 1, 3), List.of(2, 0, 3), List.of(2, 1, 3));
List<List<Integer>> list1 = AllPathsFromSourceToTarget.allPathsFromSourceToTarget(vertices, a, source, destination);
list2 = list1;
assertIterableEquals(list1, list2);
}
@Test
voidtestForSecondCase() {
intvertices = 5;
int[][] a = {{0, 1}, {0, 2}, {0, 3}, {2, 0}, {2, 1}, {1, 3}, {1, 4}, {3, 4}, {2, 4}};
intsource = 0;
intdestination = 4;
List<List<Integer>> list2 = List.of(List.of(0, 1, 3, 4), List.of(0, 1, 4), List.of(0, 2, 1, 3, 4), List.of(0, 2, 1, 4), List.of(0, 2, 4), List.of(0, 3, 4));
List<List<Integer>> list1 = AllPathsFromSourceToTarget.allPathsFromSourceToTarget(vertices, a, source, destination);
list2 = list1;
assertIterableEquals(list1, list2);
}
@Test
voidtestForThirdCase() {
intvertices = 6;
int[][] a = {{1, 0}, {2, 3}, {0, 4}, {1, 5}, {4, 3}, {0, 2}, {0, 3}, {1, 2}, {0, 5}, {3, 4}, {2, 5}, {2, 4}};
intsource = 1;
intdestination = 5;
List<List<Integer>> list2 = List.of(List.of(1, 0, 2, 5), List.of(1, 0, 5), List.of(1, 5), List.of(1, 2, 5));
List<List<Integer>> list1 = AllPathsFromSourceToTarget.allPathsFromSourceToTarget(vertices, a, source, destination);
list2 = list1;
assertIterableEquals(list1, list2);
}
@Test
voidtestForFourthcase() {
intvertices = 3;
int[][] a = {{0, 1}, {0, 2}, {1, 2}};
intsource = 0;
intdestination = 2;
List<List<Integer>> list2 = List.of(List.of(0, 1, 2), List.of(0, 2));
List<List<Integer>> list1 = AllPathsFromSourceToTarget.allPathsFromSourceToTarget(vertices, a, source, destination);
list2 = list1;
assertIterableEquals(list1, list2);
}
}