Vcsn  2.2a
Be Rational
is-complete.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <set>
4 
5 #include <vcsn/dyn/automaton.hh>
6 #include <vcsn/dyn/fwd.hh>
7 
8 namespace vcsn
9 {
12  template <Automaton Aut>
13  bool is_complete(const Aut& aut)
14  {
15  static_assert(labelset_t_of<Aut>::is_free(),
16  "is_complete: requires free labelset");
17 
18  if (aut->num_initials() == 0)
19  return false;
20 
21  using label_set_t = std::set<typename labelset_t_of<Aut>::letter_t>;
22 
23  const auto& letters = aut->labelset()->generators();
24  for (auto state : aut->states())
25  {
26  label_set_t missing_letters = {std::begin(letters), std::end(letters)};
27 
28  for (auto tr : all_out(aut, state))
29  missing_letters.erase(aut->label_of(tr));
30 
31  if (!missing_letters.empty())
32  return false;
33  }
34 
35  return true;
36  }
37 
38  /*------------------.
39  | dyn::is-complete. |
40  `------------------*/
41 
42  namespace dyn
43  {
44  namespace detail
45  {
47  template <Automaton Aut>
48  bool is_complete(const automaton& aut)
49  {
50  return is_complete(aut->as<Aut>());
51  }
52  }
53  }
54 }
A dyn automaton.
Definition: automaton.hh:19
bool is_complete(const Aut &aut)
Whether aut is complete.
Definition: is-complete.hh:13
auto all_out(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions leaving state s.
Definition: automaton.hh:37
bool is_complete(const automaton &aut)
Bridge.
Definition: is-complete.hh:48
auto & as()
Extract wrapped typed automaton.
Definition: automaton.hh:39
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
Definition: traits.hh:55
Definition: a-star.hh:8