11 template <
typename Aut>
16 "complete: requires free labelset");
18 using automaton_t = Aut;
23 state_t sink = aut->null_state();
24 const auto& ls = *aut->labelset();
26 if (aut->num_initials() == 0)
28 sink = aut->new_state();
29 aut->set_initial(sink);
33 std::unordered_set<letter_t> labels_met;
34 for (
auto st : aut->states())
38 for (
auto tr : aut->out(st))
39 labels_met.insert(aut->label_of(tr));
41 for (
auto letter : ls.genset())
42 if (!
has(labels_met, letter))
44 if (sink == aut->null_state())
45 sink = aut->new_state();
46 aut->new_transition(st, sink, letter);
52 if (sink != aut->null_state())
53 for (
auto letter : ls.genset())
54 aut->new_transition(sink, sink, letter);
59 template <
typename Aut>
74 template <
typename Aut>
78 const auto& a = aut->as<Aut>();
automaton complete(const automaton &aut)
Bridge.
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
AutOut copy(const AutIn &input, KeepState keep_state, KeepTrans keep_trans)
A copy of input keeping only its states that are accepted by keep_state.
std::shared_ptr< detail::automaton_base > automaton
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
Aut & complete_here(Aut &aut)
Complete aut and return it.
ATTRIBUTE_PURE bool has(const std::deque< T, Allocator > &s, const T &e)
Whether e is member of s.
auto complete(const Aut &aut) -> decltype(::vcsn::copy(aut))