@Test public void emptyIfGraphDoesntContainEndVertex() { builder.getGraph().removeVertex(END_VERTEX); UnreachableChangesOperation unreachableChangesOperation = new UnreachableChangesOperation(); MapResult<String, Set<String>> result = unreachableChangesOperation.execute(builder.getGraph()); assertTrue(result.get().isEmpty()); }
@Override public MapResult<String, Set<String>> execute(Graph<Vertex, Edge> graph) { ShortestPathAlgorithm<Vertex, Edge> algorithm = new BellmanFordShortestPath<>(graph); return new MapResult<>(emptyIfFalse(graph.containsVertex(END_VERTEX) && graph.containsVertex(START_VERTEX), () -> graph.edgesOf(END_VERTEX).stream() .map(Edge::getTarget) .filter(v -> algorithm.getPath(v, START_VERTEX) == null)) .stream().collect(toMapActorAction)); }
UnreachableChangesOperation extends AbstractGraphOperation<MapResult<String, Set<String>>> { @Override public MapResult<String, Set<String>> execute(Graph<Vertex, Edge> graph) { ShortestPathAlgorithm<Vertex, Edge> algorithm = new BellmanFordShortestPath<>(graph); return new MapResult<>(emptyIfFalse(graph.containsVertex(END_VERTEX) && graph.containsVertex(START_VERTEX), () -> graph.edgesOf(END_VERTEX).stream() .map(Edge::getTarget) .filter(v -> algorithm.getPath(v, START_VERTEX) == null)) .stream().collect(toMapActorAction)); } }
UnreachableChangesOperation extends AbstractGraphOperation<MapResult<String, Set<String>>> { @Override public MapResult<String, Set<String>> execute(Graph<Vertex, Edge> graph) { ShortestPathAlgorithm<Vertex, Edge> algorithm = new BellmanFordShortestPath<>(graph); return new MapResult<>(emptyIfFalse(graph.containsVertex(END_VERTEX) && graph.containsVertex(START_VERTEX), () -> graph.edgesOf(END_VERTEX).stream() .map(Edge::getTarget) .filter(v -> algorithm.getPath(v, START_VERTEX) == null)) .stream().collect(toMapActorAction)); } UnreachableChangesOperation(); }
UnreachableChangesOperation extends AbstractGraphOperation<MapResult<String, Set<String>>> { @Override public MapResult<String, Set<String>> execute(Graph<Vertex, Edge> graph) { ShortestPathAlgorithm<Vertex, Edge> algorithm = new BellmanFordShortestPath<>(graph); return new MapResult<>(emptyIfFalse(graph.containsVertex(END_VERTEX) && graph.containsVertex(START_VERTEX), () -> graph.edgesOf(END_VERTEX).stream() .map(Edge::getTarget) .filter(v -> algorithm.getPath(v, START_VERTEX) == null)) .stream().collect(toMapActorAction)); } UnreachableChangesOperation(); @Override MapResult<String, Set<String>> execute(Graph<Vertex, Edge> graph); }
UnreachableChangesOperation extends AbstractGraphOperation<MapResult<String, Set<String>>> { @Override public MapResult<String, Set<String>> execute(Graph<Vertex, Edge> graph) { ShortestPathAlgorithm<Vertex, Edge> algorithm = new BellmanFordShortestPath<>(graph); return new MapResult<>(emptyIfFalse(graph.containsVertex(END_VERTEX) && graph.containsVertex(START_VERTEX), () -> graph.edgesOf(END_VERTEX).stream() .map(Edge::getTarget) .filter(v -> algorithm.getPath(v, START_VERTEX) == null)) .stream().collect(toMapActorAction)); } UnreachableChangesOperation(); @Override MapResult<String, Set<String>> execute(Graph<Vertex, Edge> graph);  }