@ Nonnull public List < S > bfsStates ( ) { List < S > stateList = new ArrayList <> ( ) ; Set < S > visited = new HashSet <> ( ) ; int ptr = 0 ; stateList . add ( root ) ; visited . add ( root ) ; int numStates = 1 ; while ( ptr < numStates ) { S curr = stateList . get ( ptr ++ ) ; for ( int i = 0 ; i < alphabetSize ; i ++ ) { S succ = curr . getSuccessor ( i ) ; if ( succ != null && visited . add ( succ ) ) { stateList . add ( succ ) ; numStates ++ ; } } } return stateList ; }
Retrieves a list of all states in this PTA that are reachable from the root state . The states will be returned in breadth - first order .