@Test public void testPruneRoot() { Edge e1 = new Edge(STATE1, STATE2, IDENTITY); Edge e2 = new Edge(STATE2, STATE3, IDENTITY); assertThat( optimize(ImmutableSet.of(e1, e2), ImmutableSet.of(STATE2, STATE3), false), contains(e2)); }
private static Collection<StateExpr> pruneRoot( StateExpr root, Multimap<StateExpr, StateExpr> postStates, Multimap<StateExpr, StateExpr> preStates, BiConsumer<StateExpr, StateExpr> removeEdge, Set<StateExpr> statesToKeep) { assert !statesToKeep.contains(root); assert !preStates.containsKey(root); Collection<StateExpr> successors = postStates.removeAll(root); for (StateExpr successor : successors) { removeEdge.accept(root, successor); preStates.remove(successor, root); } return successors.stream() .filter(s -> postStates.containsKey(s) || preStates.containsKey(s)) .collect(Collectors.toList()); }
BDDReachabilityGraphOptimizer { private static Collection<StateExpr> pruneRoot( StateExpr root, Multimap<StateExpr, StateExpr> postStates, Multimap<StateExpr, StateExpr> preStates, BiConsumer<StateExpr, StateExpr> removeEdge, Set<StateExpr> statesToKeep) { assert !statesToKeep.contains(root); assert !preStates.containsKey(root); Collection<StateExpr> successors = postStates.removeAll(root); for (StateExpr successor : successors) { removeEdge.accept(root, successor); preStates.remove(successor, root); } return successors.stream() .filter(s -> postStates.containsKey(s) || preStates.containsKey(s)) .collect(Collectors.toList()); } }
BDDReachabilityGraphOptimizer { private static Collection<StateExpr> pruneRoot( StateExpr root, Multimap<StateExpr, StateExpr> postStates, Multimap<StateExpr, StateExpr> preStates, BiConsumer<StateExpr, StateExpr> removeEdge, Set<StateExpr> statesToKeep) { assert !statesToKeep.contains(root); assert !preStates.containsKey(root); Collection<StateExpr> successors = postStates.removeAll(root); for (StateExpr successor : successors) { removeEdge.accept(root, successor); preStates.remove(successor, root); } return successors.stream() .filter(s -> postStates.containsKey(s) || preStates.containsKey(s)) .collect(Collectors.toList()); } private  BDDReachabilityGraphOptimizer(
      Collection<Edge> edges, Set<StateExpr> statesToKeep, boolean keepSelfLoops); }
BDDReachabilityGraphOptimizer { private static Collection<StateExpr> pruneRoot( StateExpr root, Multimap<StateExpr, StateExpr> postStates, Multimap<StateExpr, StateExpr> preStates, BiConsumer<StateExpr, StateExpr> removeEdge, Set<StateExpr> statesToKeep) { assert !statesToKeep.contains(root); assert !preStates.containsKey(root); Collection<StateExpr> successors = postStates.removeAll(root); for (StateExpr successor : successors) { removeEdge.accept(root, successor); preStates.remove(successor, root); } return successors.stream() .filter(s -> postStates.containsKey(s) || preStates.containsKey(s)) .collect(Collectors.toList()); } private  BDDReachabilityGraphOptimizer(
      Collection<Edge> edges, Set<StateExpr> statesToKeep, boolean keepSelfLoops); static Collection<Edge> optimize(
      Collection<Edge> edges, Set<StateExpr> statesToKeep, boolean keepSelfLoops); }
BDDReachabilityGraphOptimizer { private static Collection<StateExpr> pruneRoot( StateExpr root, Multimap<StateExpr, StateExpr> postStates, Multimap<StateExpr, StateExpr> preStates, BiConsumer<StateExpr, StateExpr> removeEdge, Set<StateExpr> statesToKeep) { assert !statesToKeep.contains(root); assert !preStates.containsKey(root); Collection<StateExpr> successors = postStates.removeAll(root); for (StateExpr successor : successors) { removeEdge.accept(root, successor); preStates.remove(successor, root); } return successors.stream() .filter(s -> postStates.containsKey(s) || preStates.containsKey(s)) .collect(Collectors.toList()); } private  BDDReachabilityGraphOptimizer(
      Collection<Edge> edges, Set<StateExpr> statesToKeep, boolean keepSelfLoops); static Collection<Edge> optimize(
      Collection<Edge> edges, Set<StateExpr> statesToKeep, boolean keepSelfLoops);  }