| 88 | } |
| 89 | |
| 90 | @Test |
| 91 | public void testDirectedPathSearch() { |
| 92 | IVert v1 = directedGraph.getVertex(1); |
| 93 | for(int i = 2; i < 5; i++) { |
| 94 | IVert vOther = directedGraph.getVertex(i); |
| 95 | // Use DFS to find the path between v1 and vOther |
| 96 | Search<Integer> search = new DepthFirstSearch<>(); |
| 97 | SearchResult<Integer> result = search.find(v1, vOther); |
| 98 | assertNotNull(result); |
| 99 | } |
| 100 | IVert v5 = directedGraph.getVertex(5); |
| 101 | for(int i = 1; i < 4; i++) { |
| 102 | IVert vOther = directedGraph.getVertex(i); |
| 103 | // Use DFS to ensure no path exists between v5 and vOther |
| 104 | Search<Integer> search = new DepthFirstSearch<>(); |
| 105 | SearchResult<Integer> result = search.find(v5, vOther); |
| 106 | assertNull(result); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | @Test |
| 111 | public void testDirectedChildren() { |