UndirectedGraphImpl implements UndirectedGraph<V, E> { @Override public List<TIntArrayList> findAllPaths(int from, Function<V, Boolean> pathComplete, Function<E, Boolean> pathCancelled) { Objects.requireNonNull(pathComplete); List<TIntArrayList> paths = new ArrayList<>(); BitSet encountered = new BitSet(vertices.size()); TIntArrayList path = new TIntArrayList(1); findAllPaths(from, pathComplete, pathCancelled, path, encountered, paths); paths.sort((o1, o2) -> o1.size() - o2.size()); return paths; }  @Override int addVertex(); @Override void addVertexIfNotPresent(int v); @Override boolean vertexExists(int v); @Override V removeVertex(int v); @Override int getVertexCount(); @Override void removeAllVertices(); @Override int addEdge(int v1, int v2, E obj); @Override E removeEdge(int e); @Override void removeAllEdges(); @Override int getEdgeCount(); @Override int[] getVertices(); @Override int[] getEdges(); @Override int getVertexCapacity(); @Override Iterable<V> getVerticesObj(); @Override Stream<V> getVertexObjectStream(); @Override V getVertexObject(int v); @Override void setVertexObject(int v, V obj); @Override int getEdgeVertex1(int e); @Override int getEdgeVertex2(int e); @Override Iterable<E> getEdgesObject(); @Override Stream<E> getEdgeObjectStream(); @Override E getEdgeObject(int e); @Override List<E> getEdgeObjects(int v1, int v2); @Override void traverse(int v, Traverser traverser, boolean[] encountered); @Override void traverse(int v, Traverser traverser); @Override List<TIntArrayList> findAllPaths(int from, Function<V, Boolean> pathComplete, Function<E, Boolean> pathCancelled); @Override void addListener(UndirectedGraphListener l); @Override void removeListener(UndirectedGraphListener l); @Override void print(PrintStream out, Function<V, String> vertexToString, Function<E, String> edgeToString);  }
@Test public void testFindAllPaths() { graph.addVertex(); graph.addVertex(); graph.addVertex(); graph.addVertex(); graph.addVertex(); graph.addVertex(); graph.setVertexObject(5, new Vertex("end")); graph.addEdge(0, 1, null); graph.addEdge(0, 2, null); graph.addEdge(0, 3, null); graph.addEdge(1, 4, null); graph.addEdge(2, 4, null); graph.addEdge(4, 5, null); graph.addEdge(3, 5, null); List<TIntArrayList> paths = graph.findAllPaths(0, vertex -> vertex != null && "end".equals(vertex.name), null); assertEquals(3, paths.size()); assertArrayEquals(paths.get(0).toArray(), new int[] {2, 6}); assertArrayEquals(paths.get(1).toArray(), new int[] {0, 3, 5}); assertArrayEquals(paths.get(2).toArray(), new int[] {1, 4, 5}); }