/** * Checks if the NBA is deterministic (every edge has at most one target state). */ public bool isDeterministic() { //for (iterator state_it = begin(); state_it != end(); ++state_it) for (int i = 0; i < this._index.Count; i++) { NBA_State state = this._index[i]; //for (edge_iterator edge_it = state.edges_begin(); edge_it != state.edges_end(); ++edge_it) //BitSet[] edges = state._edge_manager._container._storage; //foreach (BitSet edge in edges) for (KeyValuePair <APElement, BitSet> edge = state.edges_begin(); !state.edges_end(); edge = state.increment()) { //edge_type edge = edge_it; if (edge.Value.cardinality() > 1) { return(false); } } } return(true); }
/** * Calculate the set of states that are accepting and have a true self loop. */ public void calculateAcceptingTrueLoops() { _accepting_true_loops = new BitSet(); //BitSet isAcceptingTrueLoop= *_accepting_true_loops; BitSet isAcceptingTrueLoop = _accepting_true_loops;////////changed SCCs sccs = getSCCs(); for (int scc = 0; scc < sccs.countSCCs(); ++scc) { if (sccs[scc].cardinality() == 1) { int state_id = sccs[scc].nextSetBit(0); NBA_State state = _nba[state_id]; if (!state.isFinal()) { // not final, consider next continue; } if (!sccs.successors(scc).isEmpty())//////////note here { // there are edges leaving this state, consider next continue; } bool no_empty_to = true; if (sccs.stateIsReachable(state_id, state_id)) { // state has at least one self-loop // we have to check that there is no edge with empty To //for (typename NBA_t::edge_iterator eit=state->edges_begin(); eit!=state->edges_end(); ++eit) //BitSet[] edges = state._edge_manager._container._storage; //foreach (BitSet eit in edges) for (KeyValuePair <APElement, BitSet> eit = state.edges_begin(); !state.edges_end(); eit = state.increment()) { BitSet edge = eit.Value; if (edge.isEmpty()) { // not all edges lead back to the state... no_empty_to = false; break; } } if (no_empty_to) { // When we are here the state is a final true loop isAcceptingTrueLoop.set(state_id); // std::cerr << "True Loop: " << state_id << std::endl; } } } } }