Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
ExactMultiNondeterministicSubsequenceAutomaton.h
Go to the documentation of this file.
1
6#pragma once
7
9#include <string/LinearString.h>
10
11#include <alib/pair>
12
13namespace stringology {
14
15namespace indexing {
16
18public:
23 template < class SymbolType >
25};
26
27template < class SymbolType >
30 res.addFinalState ( ext::make_pair ( 0u, 0u ) );
31
32 unsigned j = 1;
33 for ( const string::LinearString < SymbolType > & text : texts ) {
34 res.addInputSymbols ( text.getAlphabet ( ) );
35
36 res.addState ( ext::make_pair ( 0u, j ) );
37 res.addFinalState ( ext::make_pair ( 0u, j ) );
38 res.addTransition ( ext::make_pair ( 0u, 0u ), ext::make_pair ( 0u, j ) );
39
40 unsigned i = 1;
41 for ( const SymbolType & symbol : text.getContent ( ) ) {
42 res.addState ( ext::make_pair ( i, j ) );
43 res.addFinalState ( ext::make_pair ( i, j ) );
44
45 res.addTransition ( ext::make_pair ( i - 1, j ), symbol, ext::make_pair ( i, j ) );
46 res.addTransition ( ext::make_pair ( i - 1, j ), ext::make_pair ( i, j ) );
47 i++;
48 }
49 j++;
50 }
51
52 return res;
53}
54
55} /* namespace indexing */
56
57} /* namespace stringology */
58
Epsilon nondeterministic finite automaton. Accepts regular languages.
Definition: EpsilonNFA.h:74
Definition: set.hpp:44
Linear string.
Definition: LinearString.h:57
Definition: ExactMultiNondeterministicSubsequenceAutomaton.h:17
static automaton::EpsilonNFA< SymbolType, ext::pair< unsigned, unsigned > > construct(const ext::set< string::LinearString< SymbolType > > &texts)
Definition: ExactMultiNondeterministicSubsequenceAutomaton.h:28
int i
Definition: AllEpsilonClosure.h:118
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
return res
Definition: MinimizeByPartitioning.h:145
constexpr auto make_pair(T1 &&x, T2 &&y)
Definition: pair.hpp:79
Definition: ArithmeticCompression.h:18