private static boolean isFinite(Transition scratch,Automaton a,int state,BitSet path,BitSet visited){
  path.set(state);
  int numTransitions=a.initTransition(state,scratch);
  for (int t=0; t < numTransitions; t++) {
    a.getTransition(state,t,scratch);
    if (path.get(scratch.dest) || (!visited.get(scratch.dest) && !isFinite(scratch,a,scratch.dest,path,visited))) {
      return false;
    }
  }
  path.clear(state);
  visited.set(state);
  return true;
}

private static boolean isFinite ( Transition scratch , Automaton a , int state , BitSet path , BitSet visited ) { path . set ( state ) ; int numTransitions = a . initTransition ( state , scratch ) ; for ( int t = 0 ; t < numTransitions ; t ++ ) { a . getTransition ( state , t , scratch ) ; if ( path . get ( scratch . dest ) || ( ! visited . get ( scratch . dest ) && ! isFinite ( scratch , a , scratch . dest , path , visited ) ) ) { return false ; } } path . clear ( state ) ; visited . set ( state ) ; return true ; }
checks whether there is a loop containing state . ( this is sufficient since there are never transitions to dead states . )
