public DependencyGraph findLongestCallChain(){
  int depth=0;
  DependencyGraph deepest=null;
  for (  Object dep : vertices.keySet()) {
    int itsDepth=getDepth(dep);
    if (itsDepth > depth) {
      deepest=getSubGraph(dep);
      depth=itsDepth;
    }
  }
  return deepest;
}

public DependencyGraph findLongestCallChain ( ) { int depth = 0 ; DependencyGraph deepest = null ; for ( Object dep : vertices . keySet ( ) ) { int itsDepth = getDepth ( dep ) ; if ( itsDepth > depth ) { deepest = getSubGraph ( dep ) ; depth = itsDepth ; } } return deepest ; }
this will find the longest call chain in the graph . if a cycle is detected it will be returned . otherwise all subgraphs are traversed to find the one that has the most depth . this usually indicates the thread that is blocking the most other threads . < p > the finddependencieswith method can then be used to find all top - level threads that are blocked by the culprit .
