19#ifndef LIBSEMIGROUPS_DETAIL_FELSCH_TREE_HPP_
20#define LIBSEMIGROUPS_DETAIL_FELSCH_TREE_HPP_
25#include "libsemigroups/debug.hpp"
26#include "libsemigroups/types.hpp"
28#include "libsemigroups/detail/containers.hpp"
35 using index_type = size_t;
36 using state_type = size_t;
37 using const_iterator = std::vector<index_type>::const_iterator;
38 using word_iterator =
typename std::vector<word_type>::const_iterator;
40 static constexpr state_type initial_state = 0;
43 DynamicArray2<state_type> _automata;
44 state_type _current_state;
45 std::vector<std::vector<index_type>> _index;
46 std::vector<state_type> _parent;
50 explicit FelschTree(
size_t n);
53 FelschTree() =
default;
54 FelschTree(FelschTree
const&) =
default;
55 FelschTree(FelschTree&&) =
default;
56 FelschTree& operator=(FelschTree
const&) =
default;
57 FelschTree& operator=(FelschTree&&) =
default;
61 void add_relations(word_iterator first, word_iterator last);
65 _current_state = _automata.get(initial_state, x);
71 LIBSEMIGROUPS_ASSERT(x < _automata.number_of_cols());
72 auto y = _automata.get(_current_state, x);
73 if (y != initial_state) {
83 LIBSEMIGROUPS_ASSERT(_length > 0);
85 _current_state = _parent[_current_state];
88 const_iterator cbegin()
const {
89 LIBSEMIGROUPS_ASSERT(_current_state < _index.size());
90 return _index[_current_state].cbegin();
93 const_iterator cend()
const {
94 LIBSEMIGROUPS_ASSERT(_current_state < _index.size());
95 return _index[_current_state].cend();
98 size_t length() const noexcept {
102 size_t number_of_nodes() const noexcept {
103 return _parent.size();
106 size_t height() const noexcept;
size_t letter_type
Type for the index of a generator of a semigroup.
Definition types.hpp:98
Namespace for everything in the libsemigroups library.
Definition action.hpp:44