private static Graph thirdPass(Graph graph) {
    List<String> vertices = graph.getVertices();
    
    Set<Integer> intersect = new HashSet<Integer>();
    for (int x = 0; x < vertices.size(); x++) {
      intersect.add(x);
    }
    
    for (int x = 0; x < vertices.size(); x++) {
      Set<Integer> reachable = GraphUtils.searchForward(graph, x);
      reachable.addAll(GraphUtils.searchBackward(graph, x));
      
      intersect.retainAll(reachable);
    }
    
    List<String> newvertices = new ArrayList<String>(intersect.size());
    for (int vertex : intersect) {
      newvertices.add(vertices.get(vertex));
    }
    
    return GraphMaker.makeGraph(newvertices, TEMP_NAME);
  }