Skip to content
Snippets Groups Projects
Commit 3d41ae59 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

algo: fixes in automata union algo

parent e29f86bd
No related branches found
No related tags found
1 merge request!164algo: fixes in automata union algo
Pipeline #94214 passed with warnings
......@@ -87,10 +87,13 @@ automaton::EpsilonNFA < SymbolType, ext::pair < StateType, unsigned > > Automata
for(const auto& q : second.getFinalStates())
res.addFinalState ( ext::make_pair ( q, secondDefault ) );
 
if ( first.getFinalStates ( ).contains ( first.getInitialState ( ) ) || second.getFinalStates ( ).contains ( second.getInitialState ( ) ) )
res.addFinalState ( q0 );
for ( const auto & t : first.getTransitionsFromState ( first.getInitialState ( ) ) )
res.addTransition ( q0, t.first.first, ext::make_pair ( t.second, firstDefault ) );
res.addTransition ( q0, t.first.second, ext::make_pair ( t.second, firstDefault ) );
for ( const auto & t : second.getTransitionsFromState ( second.getInitialState ( ) ) )
res.addTransition ( q0, t.first.first, ext::make_pair ( t.second, secondDefault ) );
res.addTransition ( q0, t.first.second, ext::make_pair ( t.second, secondDefault ) );
 
for(const auto& t : first.getTransitions())
res.addTransition ( ext::make_pair ( t.first.first, firstDefault ), t.first.second, ext::make_pair ( t.second, firstDefault ) );
......@@ -124,10 +127,13 @@ automaton::NFA < SymbolType, ext::pair < StateType, unsigned > > AutomataUnion::
for(const auto& q : second.getFinalStates())
res.addFinalState ( ext::make_pair ( q, secondDefault ) );
 
if ( first.getFinalStates ( ).contains ( first.getInitialState ( ) ) || second.getFinalStates ( ).contains ( second.getInitialState ( ) ) )
res.addFinalState ( q0 );
for ( const auto & t : first.getTransitionsFromState ( first.getInitialState ( ) ) )
res.addTransition ( q0, t.first.first, ext::make_pair ( t.second, firstDefault ) );
res.addTransition ( q0, t.first.second, ext::make_pair ( t.second, firstDefault ) );
for ( const auto & t : second.getTransitionsFromState ( second.getInitialState ( ) ) )
res.addTransition ( q0, t.first.first, ext::make_pair ( t.second, secondDefault ) );
res.addTransition ( q0, t.first.second, ext::make_pair ( t.second, secondDefault ) );
 
for(const auto& t : first.getTransitions())
res.addTransition ( ext::make_pair ( t.first.first, firstDefault ), t.first.second, ext::make_pair ( t.second, firstDefault ) );
......@@ -161,10 +167,13 @@ automaton::NFA < SymbolType, ext::pair < StateType, unsigned > > AutomataUnion::
for(const auto& q : second.getFinalStates())
res.addFinalState ( ext::make_pair ( q, secondDefault ) );
 
if ( first.getFinalStates ( ).contains ( first.getInitialState ( ) ) || second.getFinalStates ( ).contains ( second.getInitialState ( ) ) )
res.addFinalState ( q0 );
for ( const auto & t : first.getTransitionsFromState ( first.getInitialState ( ) ) )
res.addTransition ( q0, t.first.first, ext::make_pair ( t.second, firstDefault ) );
res.addTransition ( q0, t.first.second, ext::make_pair ( t.second, firstDefault ) );
for ( const auto & t : second.getTransitionsFromState ( second.getInitialState ( ) ) )
res.addTransition ( q0, t.first.first, ext::make_pair ( t.second, secondDefault ) );
res.addTransition ( q0, t.first.second, ext::make_pair ( t.second, secondDefault ) );
 
for(const auto& t : first.getTransitions())
res.addTransition ( ext::make_pair ( t.first.first, firstDefault ), t.first.second, ext::make_pair ( t.second, firstDefault ) );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment