public static boolean isEmpty(Automaton a){
  if (a.getNumStates() == 0) {
    return true;
  }
  if (a.isAccept(0) == false && a.getNumTransitions(0) == 0) {
    return true;
  }
  if (a.isAccept(0) == true) {
    return false;
  }
  LinkedList<Integer> workList=new LinkedList<>();
  BitSet seen=new BitSet(a.getNumStates());
  workList.add(0);
  seen.set(0);
  Transition t=new Transition();
  while (workList.isEmpty() == false) {
    int state=workList.removeFirst();
    if (a.isAccept(state)) {
      return false;
    }
    int count=a.initTransition(state,t);
    for (int i=0; i < count; i++) {
      a.getNextTransition(t);
      if (seen.get(t.dest) == false) {
        workList.add(t.dest);
        seen.set(t.dest);
      }
    }
  }
  return true;
}

public static boolean isEmpty ( Automaton a ) { if ( a . getNumStates ( ) == 0 ) { return true ; } if ( a . isAccept ( 0 ) == false && a . getNumTransitions ( 0 ) == 0 ) { return true ; } if ( a . isAccept ( 0 ) == true ) { return false ; } LinkedList < Integer > workList = new LinkedList < > ( ) ; BitSet seen = new BitSet ( a . getNumStates ( ) ) ; workList . add ( 0 ) ; seen . set ( 0 ) ; Transition t = new Transition ( ) ; while ( workList . isEmpty ( ) == false ) { int state = workList . removeFirst ( ) ; if ( a . isAccept ( state ) ) { return false ; } int count = a . initTransition ( state , t ) ; for ( int i = 0 ; i < count ; i ++ ) { a . getNextTransition ( t ) ; if ( seen . get ( t . dest ) == false ) { workList . add ( t . dest ) ; seen . set ( t . dest ) ; } } } return true ; }
returns true if the given automaton accepts no strings .
