private boolean visitCycle(Object start,Set<Object> unvisited,Set<Object> finished,CycleHolder cycle,int depth){
  if (finished.contains(start)) {
    return false;
  }
  if (!unvisited.remove(start)) {
    return true;
  }
  cycle.processDepth(depth);
  boolean foundCycle=false;
  for (  Dependency dep : vertices.get(start)) {
    foundCycle|=visitCycle(dep.getDependsOn(),unvisited,finished,cycle,depth + 1);
    if (foundCycle) {
      cycle.add(dep);
      break;
    }
  }
  finished.add(start);
  return foundCycle;
}

private boolean visitCycle ( Object start , Set < Object > unvisited , Set < Object > finished , CycleHolder cycle , int depth ) { if ( finished . contains ( start ) ) { return false ; } if ( ! unvisited . remove ( start ) ) { return true ; } cycle . processDepth ( depth ) ; boolean foundCycle = false ; for ( Dependency dep : vertices . get ( start ) ) { foundCycle |= visitCycle ( dep . getDependsOn ( ) , unvisited , finished , cycle , depth + 1 ) ; if ( foundCycle ) { cycle . add ( dep ) ; break ; } } finished . add ( start ) ; return foundCycle ; }
visit a vertex for the purposes of finding a cycle in the graph .
