diff --git a/arand/src/RandomAutomatonFactory.cpp b/arand/src/RandomAutomatonFactory.cpp index f539e470a10604f2d1d1de1697c3befcd2b04022..5f6d2d70193774968c4b2d7f5e3d373f50aa19d4 100644 --- a/arand/src/RandomAutomatonFactory.cpp +++ b/arand/src/RandomAutomatonFactory.cpp @@ -122,7 +122,7 @@ FSM RandomAutomatonFactory::LeslieConnectedNFA( size_t n, const deque<Symbol> & // --------- } - for( State q : Q ) + for( State const& q : Q ) { if( automata.getTransitionsFromState( q ).size( ) == 0 && rand( ) % 100 < 90 ) automata.addFinalState( q ); @@ -133,10 +133,20 @@ FSM RandomAutomatonFactory::LeslieConnectedNFA( size_t n, const deque<Symbol> & if( automata.getFinalStates( ).size( ) == 0 ) { if( n == 1 ) + { automata.addFinalState( * automata.getInitialStates( ).begin( ) ); + } else - //todo: change - automata.addFinalState( * automata.getInitialStates( ).begin( ) ); + { + for( State const& q : Q ) + { + if( automata.getTransitionsFromState( q ).size( ) == 0 ) + { + automata.addFinalState( q ); + break; + } + } + } } double mnn100 = 100.0 / alphabet.size( ) / n / n;