()
| 150 | } |
| 151 | |
| 152 | @Test |
| 153 | public void testGetAllRoots() { |
| 154 | IVert v1 = directedGraph.getVertex(1); |
| 155 | IVert v4 = directedGraph.getVertex(4); |
| 156 | IVert v5 = directedGraph.getVertex(5); |
| 157 | IVert v6 = directedGraph.getVertex(6); |
| 158 | // 5 -> 6 (root) |
| 159 | // 5 -> 3 -> 1 (root) |
| 160 | Set<Vertex<Integer>> roots = v5.getAllRoots().collect(Collectors.toSet()); |
| 161 | assertTrue(roots.contains(v1)); |
| 162 | assertTrue(roots.contains(v6)); |
| 163 | assertEquals(2, roots.size()); |
| 164 | // 4 -> 2 -> 1 (root) |
| 165 | roots = v4.getAllRoots().collect(Collectors.toSet()); |
| 166 | assertTrue(roots.contains(v1)); |
| 167 | assertEquals(1, roots.size()); |
| 168 | // 1 (root) |
| 169 | roots = v1.getAllRoots().collect(Collectors.toSet()); |
| 170 | assertTrue(roots.contains(v1)); |
| 171 | assertEquals(1, roots.size()); |
| 172 | } |
| 173 | |
| 174 | @Test |
| 175 | public void testIsDirectedLeaf() { |
nothing calls this directly
no test coverage detected