Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
NondeterministicExactSuffixAutomaton.h
Go to the documentation of this file.
1
6/*
7 * Author: Radovan Cerveny
8 */
9
10#pragma once
11
12#include <automaton/FSM/NFA.h>
13#include <string/LinearString.h>
14
15namespace stringology {
16
17namespace indexing {
18
20public:
25 template < class SymbolType >
27
28};
29
30template < class SymbolType >
32 automaton::NFA < SymbolType, unsigned > nfaSuffixAutomaton ( 0 );
33
34 nfaSuffixAutomaton.setInputAlphabet ( pattern.getAlphabet ( ) );
35
36 unsigned i = 0;
37 for ( const SymbolType & symbol : pattern.getContent ( ) ) {
38 nfaSuffixAutomaton.addState ( ++ i );
39 nfaSuffixAutomaton.addTransition ( i - 1, symbol, i );
40 nfaSuffixAutomaton.addTransition ( 0, symbol, i );
41 }
42
43 nfaSuffixAutomaton.setFinalStates ( { 0, i } );
44
45 return nfaSuffixAutomaton;
46}
47
48} /* namespace indexing */
49
50} /* namespace stringology */
51
Nondeterministic finite automaton. Accepts regular languages.
Definition: NFA.h:66
bool addState(StateType state)
Definition: NFA.h:156
void setFinalStates(ext::set< StateType > states)
Definition: NFA.h:214
void setInputAlphabet(ext::set< SymbolType > symbols)
Definition: NFA.h:272
bool addTransition(StateType from, SymbolType input, StateType to)
Add a transition to the automaton.
Definition: NFA.h:450
Linear string.
Definition: LinearString.h:57
const ext::set< SymbolType > & getAlphabet() const &
Definition: LinearString.h:103
const ext::vector< SymbolType > & getContent() const &
Definition: LinearString.h:238
Definition: NondeterministicExactSuffixAutomaton.h:19
static automaton::NFA< SymbolType, unsigned > construct(const string::LinearString< SymbolType > &pattern)
Definition: NondeterministicExactSuffixAutomaton.h:31
int i
Definition: AllEpsilonClosure.h:118
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
Definition: ArithmeticCompression.h:18