public int getDepth(V o1) {
    Set<Node<V, E>> active = new HashSet<>();
    active.add(nodeOf(o1));
    int depth = 0;
    while(!active.isEmpty()) {
      Set<Node<V, E>> newActive = new HashSet<>();
      for (Node<V, E> node : active) {
        Set<V> p = successors(node.v);
        for (V n : p) {
          newActive.add(nodeOf(n));
        }
      }
      depth++;
      active = newActive;
    }
    return depth;
  }
A directed graph extended with support to check dag property.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/graph/DagGraph.java