From 4c79af8a3cbc4962c01366f277586112ade1b980 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Pecka?= <peckato1@fit.cvut.cz>
Date: Thu, 1 May 2014 10:55:06 +0200
Subject: [PATCH] arand: fix previous commit

---
 arand/src/RandomAutomatonFactory.cpp | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/arand/src/RandomAutomatonFactory.cpp b/arand/src/RandomAutomatonFactory.cpp
index f539e470a1..5f6d2d7019 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;
-- 
GitLab