@SuppressWarnings({ "unchecked", "unused" })
  private static Graph secondPass(Graph graph) {
    boolean removed = true;
    while (removed) {
      removed = false;

      List<String> vertices = graph.getVertices();

      Set<String> remove = new HashSet<String>();
      for (int x = 0; x < graph.size(); x++) {
        List<Integer> outedges = graph.getOutEdges(x);
        Set<Integer>[] outreached = new Set[outedges.size() + 1];

        for (int y = 0; y < outedges.size(); y++) {
          outreached[y] = GraphUtils.searchForward(graph, outedges.get(y));
        }
        outreached[outedges.size()] = new HashSet<Integer>();

        List<Integer> inedges = graph.getInEdges(x);
        Set<Integer>[] inreached = new Set[inedges.size() + 1];
        for (int y = 0; y < inedges.size(); y++) {
          inreached[y] = GraphUtils.searchBackward(graph, inedges.get(y));
        }
        inreached[inedges.size()] = new HashSet<Integer>();

        boolean keep = false;
        outer: {
          for (int i = 0; i < outreached.length; i++) {
            for (int j = 0; j < inreached.length; j++) {
              Set<Integer> reached = new HashSet<Integer>(outreached[i]);
              reached.addAll(inreached[j]);
              reached.add(x);

              if (reached.size() >= GraphUtils.CANDIDATE_CUTOFF) {
                keep = true;
                break outer;
              }
            }
          }
        }

        if (!keep) {
          remove.add(vertices.get(x));
        }
      }

      System.out.println(remove.size());
      if (remove.size() > 0) {
        removed = true;
        vertices.removeAll(remove);

        graph = GraphMaker.makeGraph(vertices, TEMP_NAME);
      }
    }

    return graph;
  }