17 #ifndef AWALI_ALGOS_COMPLETE_HH
18 # define AWALI_ALGOS_COMPLETE_HH
21 # include <unordered_map>
26 namespace awali {
namespace sttc {
36 template <
typename Aut>
41 "requires free labelset");
43 using automaton_t = Aut;
47 state_t sink = aut->null_state();
48 const auto& ls = *aut->labelset();
50 if (aut->num_initials() == 0) {
51 sink = aut->add_state();
52 aut->set_initial(sink);
56 std::unordered_set<letter_t> labels_met;
57 for (
auto st : aut->states())
59 for (
auto tr : aut->out(st))
60 labels_met.insert(aut->label_of(tr));
62 for (
auto letter : ls.genset())
63 if (labels_met.find(letter)==labels_met.end()) {
64 if (sink == aut->null_state())
65 sink = aut->add_state();
66 aut->new_transition(st, sink, letter);
72 if (sink != aut->null_state())
73 for (
auto letter : ls.genset())
74 aut->new_transition(sink, sink, letter);
88 template <
typename Aut>
90 complete(
const Aut& aut,
bool keep_history=
true)
91 -> decltype(
copy(aut, keep_history))
93 auto res =
copy(aut, keep_history);
auto complete(const Aut &aut, bool keep_history=true) -> decltype(copy(aut, keep_history))
Completion of a deterministic automaton.
Definition: complete.hh:90
Aut & complete_here(Aut &aut)
Completion of a deterministic automaton.
Definition: complete.hh:38
typename internal::labelset_t_of_impl< internal::base_t< ValueSet > >::type labelset_t_of
Helper to retrieve the type of the labelset of a value set.
Definition: traits.hh:76
AutOut copy(const AutIn &input, Pred keep_state, bool keep_history=true, bool transpose=false)
A copy of input keeping only its states that are accepted by keep_state.
Definition: copy.hh:189
Main namespace of Awali.
Definition: ato.hh:22
unsigned state_t
Definition: types.hh:21