11#include <string/LinearString.h>
37 template<
class SymbolType>
42 if ( dSuffix.
getFinalStates().count( newState ) && newState.rbegin()->second <= distance )
46 for (
size_t pi = 0; pi < potentialSeed.
size(); ++pi )
48 if ( pi >= pattern.
getContent().size() - newState.rbegin()->first
50 && ( *statePtr ).rbegin()->second <= distance )
54 for (
auto tr = it_range.begin(); tr != it_range.end(); ++tr )
56 if ( tr->first.second == potentialSeed.
getContent().at( pi ) )
58 statePtr = & tr->second;
76 template<
class SymbolType>
82 if ( newState.
begin()->first == potentialSeed.
size() && newState.
begin()->second <= distance )
87 for (
size_t si = 0; si < reversedPotentialSeed.size(); ++si )
89 if( si >= newState.
begin()->first - potentialSeed.
size()
91 && ( *statePtr ).rbegin()->second <= distance )
95 for (
auto tr = it_range.begin(); tr != it_range.end(); ++tr )
97 if ( tr->first.second == reversedPotentialSeed.getContent().at( si ) )
99 statePtr = & tr->second;
115 template<
class SymbolType>
118 auto firstIt = newState.
begin();
120 for (
auto secondIt = newState.
begin(); firstIt != newState.
end(); ++firstIt, ++secondIt )
122 if ( firstIt->first - secondIt->first > potentialSeed.
size() )
140 template<
class SymbolType>
146 if ( ! potentialSeed.
empty()
147 && coversMiddle( potentialSeed, newState )
148 && existsPrefix( potentialSeed, newState, distance, dSuffix, pattern )
149 && existsSuffix( potentialSeed, newState, distance, dSuffixReversed ) )
167 template<
class SymbolType>
177 unsigned dist = distance - 1;
178 auto state = newState;
179 for (
auto it = state.begin(); it != state.end(); )
181 if ( it->second > dist )
182 it = state.erase( it );
186 while ( ! state.empty() && isSeed( seed, state, dist, dSuffix, dSuffixReversed, pattern ) )
192 for (
auto it = state.begin(); it != state.end(); )
194 if ( it->second > dist )
195 it = state.erase(it);
216 template<
class SymbolType>
217 static void DFS (
const State & state,
226 if ( ! restricted ||
std::any_of( state.
begin(), state.
end(), [](
const auto & x ) ->
bool { return x.second == 0; } ) )
230 && isSeed( lfactor, state, distance, dSuffix, dSuffixReversed, pattern ) )
232 unsigned d = smallestDistanceSeed( lfactor, state, distance, dSuffix, dSuffixReversed, pattern );
233 if ( lfactor.
size() > d )
238 for (
const auto & tr : transitions )
242 DFS( tr.second, lfactorCopy, dSuffix, dSuffixReversed,
result, pattern, distance, restricted );
258 template<
class SymbolType>
284 template<
class SymbolType>
Deterministic finite automaton. Accepts regular languages.
Definition: DFA.h:71
const ext::set< StateType > & getFinalStates() const &
Definition: DFA.h:183
const StateType & getInitialState() const &
Definition: DFA.h:105
const ext::set< SymbolType > & getInputAlphabet() const &
Definition: DFA.h:232
ext::iterator_range< typename ext::map< ext::pair< StateType, SymbolType >, StateType >::const_iterator > getTransitionsFromState(const StateType &from) const
Definition: DFA.h:483
Class extending the pair class from the standard library. Original reason is to allow printing of the...
Definition: pair.hpp:43
auto begin() &
Inherited behavior of begin for non-const instance.
Definition: set.hpp:99
auto end() &
Inherited behavior of end for non-const instance.
Definition: set.hpp:129
Linear string.
Definition: LinearString.h:57
bool empty() const
Definition: LinearString.h:258
const ext::vector< SymbolType > & getContent() const &
Definition: LinearString.h:238
void appendSymbol(SymbolType symbol)
Definition: LinearString.h:230
size_t size() const
Definition: LinearString.h:263
Definition: ApproximateSeedComputation.h:24
static ext::set< ext::pair< string::LinearString< SymbolType >, unsigned > > compute(const string::LinearString< SymbolType > &pattern, unsigned distance)
Definition: ApproximateSeedComputation.h:285
static ext::set< ext::pair< string::LinearString< SymbolType >, unsigned > > compute(const string::LinearString< SymbolType > &pattern, unsigned distance, bool restricted)
Definition: ApproximateSeedComputation.h:259
static automaton::DFA< SymbolType, StateType > construct(const string::LinearString< SymbolType > &pattern, unsigned k)
Definition: DeterministicApproximateSuffixAutomatonForHammingDistanceFactory.h:58
for(const StateType &state :fsm.getStates()) renamingData.insert(std Rename::RenamedAutomaton< T > result(renamingData.at(fsm.getInitialState()))
Definition: Rename.h:253
constexpr auto make_pair(T1 &&x, T2 &&y)
Definition: pair.hpp:79
any_of(T &&...) -> any_of< T... >
Definition: ApproximateSeedComputation.cpp:10