@Test public void testGetDominatorSetsLoopingGraph() { Map<Integer, Set<Integer>> expected = new HashMap<>(); expected.put(0, new HashSet<>(Arrays.asList(0))); expected.put(1, new HashSet<>(Arrays.asList(0, 1))); expected.put(2, new HashSet<>(Arrays.asList(0, 1, 2))); expected.put(3, new HashSet<>(Arrays.asList(0, 1, 3))); expected.put(4, new HashSet<>(Arrays.asList(0, 1, 3, 4))); expected.put(5, new HashSet<>(Arrays.asList(0, 1, 3, 4, 5))); expected.put(6, new HashSet<>(Arrays.asList(0, 1, 3, 4, 6))); expected.put(7, new HashSet<>(Arrays.asList(0, 1, 3, 4, 7))); expected.put(8, new HashSet<>(Arrays.asList(0, 1, 3, 4, 7, 8))); expected.put(9, new HashSet<>(Arrays.asList(0, 1, 3, 4, 7, 8, 9))); expected.put(10, new HashSet<>(Arrays.asList(0, 1, 3, 4, 7, 8, 10))); expected.put(11, new HashSet<>(Arrays.asList(0, 1, 3, 4, 7, 8, 10, 11))); assertEquals(expected, loopingGraph.getDominatorSets()); }
public Map<V, Set<V>> getDominatorSets() { if(dominatorSets == null) { getImmediateDominators(); dominatorSets = new HashMap<>(); for(V key : immediateDominators.keySet()) { Set<V> tempDominators = new HashSet<>(); for(V current = key; current != null; current = immediateDominators.get(current)) { tempDominators.add(current); } dominatorSets.put(key, Collections.unmodifiableSet(tempDominators)); } dominatorSets = Collections.unmodifiableMap(dominatorSets); } return dominatorSets; }
FlowGraph { public Map<V, Set<V>> getDominatorSets() { if(dominatorSets == null) { getImmediateDominators(); dominatorSets = new HashMap<>(); for(V key : immediateDominators.keySet()) { Set<V> tempDominators = new HashSet<>(); for(V current = key; current != null; current = immediateDominators.get(current)) { tempDominators.add(current); } dominatorSets.put(key, Collections.unmodifiableSet(tempDominators)); } dominatorSets = Collections.unmodifiableMap(dominatorSets); } return dominatorSets; } }
FlowGraph { public Map<V, Set<V>> getDominatorSets() { if(dominatorSets == null) { getImmediateDominators(); dominatorSets = new HashMap<>(); for(V key : immediateDominators.keySet()) { Set<V> tempDominators = new HashSet<>(); for(V current = key; current != null; current = immediateDominators.get(current)) { tempDominators.add(current); } dominatorSets.put(key, Collections.unmodifiableSet(tempDominators)); } dominatorSets = Collections.unmodifiableMap(dominatorSets); } return dominatorSets; } FlowGraph(Map<V, Set<V>> edges, V entryPoint, V exitPoint); private  FlowGraph(FlowGraph<V> originalGraph); }
FlowGraph { public Map<V, Set<V>> getDominatorSets() { if(dominatorSets == null) { getImmediateDominators(); dominatorSets = new HashMap<>(); for(V key : immediateDominators.keySet()) { Set<V> tempDominators = new HashSet<>(); for(V current = key; current != null; current = immediateDominators.get(current)) { tempDominators.add(current); } dominatorSets.put(key, Collections.unmodifiableSet(tempDominators)); } dominatorSets = Collections.unmodifiableMap(dominatorSets); } return dominatorSets; } FlowGraph(Map<V, Set<V>> edges, V entryPoint, V exitPoint); private  FlowGraph(FlowGraph<V> originalGraph); V getEntryPoint(); V getExitPoint(); Map<V, Set<V>> getSuccessors(); Map<V, Set<V>> getPredecessors(); Set<V> getVertices(); Set<V> getSuccessors(V vertex); Set<V> getPredecessors(V vertex); FlowGraph<V> getTransverseGraph(); Map<V, V> getImmediateDominators(); Map<V, Set<V>> getDominatorTree(); Map<V, Set<V>> getDominatorSets(); Map<V, Set<V>> getDominanceFrontiers(); Map<V, V> getImmediatePostDominators(); Map<V, Set<V>> getPostDominatorSets(); Map<V, Set<V>> getPostDominanceFrontiers(); Set<NaturalLoop<V>> getNaturalLoops(); boolean containsPath(V source, V target); @Override boolean equals(Object o); @Override int hashCode(); void write(Writer writer, String graphName, Comparator<V> vertexComparator,
                      Function<V, String> printer, int fontSize); }
FlowGraph { public Map<V, Set<V>> getDominatorSets() { if(dominatorSets == null) { getImmediateDominators(); dominatorSets = new HashMap<>(); for(V key : immediateDominators.keySet()) { Set<V> tempDominators = new HashSet<>(); for(V current = key; current != null; current = immediateDominators.get(current)) { tempDominators.add(current); } dominatorSets.put(key, Collections.unmodifiableSet(tempDominators)); } dominatorSets = Collections.unmodifiableMap(dominatorSets); } return dominatorSets; } FlowGraph(Map<V, Set<V>> edges, V entryPoint, V exitPoint); private  FlowGraph(FlowGraph<V> originalGraph); V getEntryPoint(); V getExitPoint(); Map<V, Set<V>> getSuccessors(); Map<V, Set<V>> getPredecessors(); Set<V> getVertices(); Set<V> getSuccessors(V vertex); Set<V> getPredecessors(V vertex); FlowGraph<V> getTransverseGraph(); Map<V, V> getImmediateDominators(); Map<V, Set<V>> getDominatorTree(); Map<V, Set<V>> getDominatorSets(); Map<V, Set<V>> getDominanceFrontiers(); Map<V, V> getImmediatePostDominators(); Map<V, Set<V>> getPostDominatorSets(); Map<V, Set<V>> getPostDominanceFrontiers(); Set<NaturalLoop<V>> getNaturalLoops(); boolean containsPath(V source, V target); @Override boolean equals(Object o); @Override int hashCode(); void write(Writer writer, String graphName, Comparator<V> vertexComparator,
                      Function<V, String> printer, int fontSize);  }