5 #include <vcsn/dyn/fwd.hh>
11 template <Automaton 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);
32 auto num_gens = ls.generators().size();
35 auto labels_met = std::unordered_set<letter_t>{};
36 for (
auto st : aut->states())
40 for (
auto tr :
out(aut, st))
41 labels_met.insert(aut->label_of(tr));
43 if (labels_met.size() < num_gens)
44 for (
auto letter : ls.generators())
45 if (!
has(labels_met, letter))
47 if (sink == aut->null_state())
48 sink = aut->new_state();
49 aut->new_transition(st, sink, letter);
55 if (sink != aut->null_state())
56 for (
auto letter : ls.generators())
57 aut->new_transition(sink, sink, letter);
63 template <Automaton Aut>
78 template <Automaton Aut>
82 const auto& a = aut->
as<Aut>();
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
automaton complete(const automaton &aut)
Bridge.
auto out(const Aut &aut, state_t_of< Aut > s)
Indexes of visible transitions leaving state s.
auto complete(const Aut &aut) -> decltype(::vcsn::copy(aut))
A complete copy of aut.
Aut & complete_here(Aut &aut)
Complete aut and return it.
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
auto copy(const AutIn &input, KeepState keep_state, KeepTrans keep_trans) -> decltype(keep_state(input->null_state()), keep_trans(input->null_transition()), make_fresh_automaton< AutIn, AutOut >(input))
A copy of input keeping only its states that are accepted by keep_state, and transitions accepted by ...
ATTRIBUTE_PURE bool has(const boost::container::flat_set< Key, Compare, Allocator > &s, const Key &e)
Whether e is member of s.
auto & as()
Extract wrapped typed automaton.