@Test public void emptyIfGraphDoesntContainEndVertex() { builder.getGraph().removeVertex(END_VERTEX); AllReachableEdgesOperation allReachableEdgesOperation = new AllReachableEdgesOperation(); SetResult<Edge> result = allReachableEdgesOperation.execute(builder.getGraph()); assertTrue(result.get().isEmpty()); }
@Override public SetResult<Edge> execute(Graph<Vertex, Edge> graph) { return new SetResult<>(emptyIfFalse(graph.containsVertex(START_VERTEX) && graph.containsVertex(END_VERTEX), () -> { AllDirectedPaths<Vertex, Edge> algorithm = new AllDirectedPaths<>((DirectedGraph<Vertex, Edge>) graph); List<GraphPath<Vertex, Edge>> ways = algorithm.getAllPaths(END_VERTEX, START_VERTEX, true, MAX_PATH_LENGTH); return ways.stream().flatMap(w -> w.getEdgeList().stream()).distinct(); })); }
AllReachableEdgesOperation extends AbstractGraphOperation<SetResult<Edge>> { @Override public SetResult<Edge> execute(Graph<Vertex, Edge> graph) { return new SetResult<>(emptyIfFalse(graph.containsVertex(START_VERTEX) && graph.containsVertex(END_VERTEX), () -> { AllDirectedPaths<Vertex, Edge> algorithm = new AllDirectedPaths<>((DirectedGraph<Vertex, Edge>) graph); List<GraphPath<Vertex, Edge>> ways = algorithm.getAllPaths(END_VERTEX, START_VERTEX, true, MAX_PATH_LENGTH); return ways.stream().flatMap(w -> w.getEdgeList().stream()).distinct(); })); } }
AllReachableEdgesOperation extends AbstractGraphOperation<SetResult<Edge>> { @Override public SetResult<Edge> execute(Graph<Vertex, Edge> graph) { return new SetResult<>(emptyIfFalse(graph.containsVertex(START_VERTEX) && graph.containsVertex(END_VERTEX), () -> { AllDirectedPaths<Vertex, Edge> algorithm = new AllDirectedPaths<>((DirectedGraph<Vertex, Edge>) graph); List<GraphPath<Vertex, Edge>> ways = algorithm.getAllPaths(END_VERTEX, START_VERTEX, true, MAX_PATH_LENGTH); return ways.stream().flatMap(w -> w.getEdgeList().stream()).distinct(); })); } AllReachableEdgesOperation(); }
AllReachableEdgesOperation extends AbstractGraphOperation<SetResult<Edge>> { @Override public SetResult<Edge> execute(Graph<Vertex, Edge> graph) { return new SetResult<>(emptyIfFalse(graph.containsVertex(START_VERTEX) && graph.containsVertex(END_VERTEX), () -> { AllDirectedPaths<Vertex, Edge> algorithm = new AllDirectedPaths<>((DirectedGraph<Vertex, Edge>) graph); List<GraphPath<Vertex, Edge>> ways = algorithm.getAllPaths(END_VERTEX, START_VERTEX, true, MAX_PATH_LENGTH); return ways.stream().flatMap(w -> w.getEdgeList().stream()).distinct(); })); } AllReachableEdgesOperation(); @Override SetResult<Edge> execute(Graph<Vertex, Edge> graph); }
AllReachableEdgesOperation extends AbstractGraphOperation<SetResult<Edge>> { @Override public SetResult<Edge> execute(Graph<Vertex, Edge> graph) { return new SetResult<>(emptyIfFalse(graph.containsVertex(START_VERTEX) && graph.containsVertex(END_VERTEX), () -> { AllDirectedPaths<Vertex, Edge> algorithm = new AllDirectedPaths<>((DirectedGraph<Vertex, Edge>) graph); List<GraphPath<Vertex, Edge>> ways = algorithm.getAllPaths(END_VERTEX, START_VERTEX, true, MAX_PATH_LENGTH); return ways.stream().flatMap(w -> w.getEdgeList().stream()).distinct(); })); } AllReachableEdgesOperation(); @Override SetResult<Edge> execute(Graph<Vertex, Edge> graph);  }