1 #ifndef VCSN_ALGOS_ACCESSIBLE_HH
2 # define VCSN_ALGOS_ACCESSIBLE_HH
21 template <
typename Aut>
22 using states_t = std::unordered_set<state_t_of<Aut>>;
25 template <
typename Aut>
29 using automaton_t = Aut;
33 const auto& a = *aptr;
37 using worklist_t = std::queue<state_t>;
39 todo.emplace(a.pre());
43 const state_t src = todo.front();
46 for (
auto tr : a.all_out(src))
48 state_t dst = a.dst_of(tr);
50 if (res.emplace(dst).second)
59 template <
typename Aut>
67 template <
typename Aut>
82 template <
typename Aut>
87 size_t res = set.size();
91 if (
has(set, a->post()))
97 template <
typename Aut>
105 template <
typename Aut>
110 size_t res = set.size();
112 if (
has(set, a->pre()))
115 if (
has(set, a->post()))
125 template <
typename Aut>
126 filter_automaton<Aut>
132 template <
typename Aut>
133 filter_automaton<Aut>
139 template <
typename Aut>
140 filter_automaton<Aut>
150 template <
typename Aut>
156 template <
typename Aut>
162 template <
typename Aut>
168 template <
typename Aut>
174 template <
typename Aut>
175 bool is_empty(
const Aut& a) ATTRIBUTE_PURE;
177 template <
typename Aut>
182 return a->num_states() == 0;
194 template <
typename Aut>
198 const auto& a = aut->as<Aut>();
209 template <
typename Aut>
213 const auto& a = aut->as<Aut>();
224 template <
typename Aut>
228 const auto& a = aut->as<Aut>();
239 template <
typename Aut>
243 const auto& a = aut->as<Aut>();
254 template <
typename Aut>
258 const auto& a = aut->as<Aut>();
269 template <
typename Aut>
273 const auto& a = aut->as<Aut>();
284 template <
typename Aut>
288 const auto& a = aut->as<Aut>();
299 template <
typename Aut>
303 const auto& a = aut->as<Aut>();
313 #endif // !VCSN_ALGOS_ACCESSIBLE_HH
filter_automaton< Aut > coaccessible(const Aut &a)
REGISTER_DECLARE(accessible,(const automaton &) -> automaton)
std::shared_ptr< detail::automaton_base > automaton
size_t num_accessible_states(const Aut &a)
Number of accessible states, not counting pre() and post().
states_t< Aut > useful_states(const Aut &a)
automaton accessible(const automaton &aut)
bool is_trim(const Aut &a)
bool is_useless(const Aut &a)
std::unordered_set< state_t_of< Aut >> states_t
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
bool is_empty(const automaton &aut)
bool is_useless(const automaton &aut)
filter_automaton< Aut > trim(const Aut &a)
bool is_trim(const automaton &aut)
states_t< Aut > accessible_states(const Aut &aptr)
bool is_empty(const Aut &a) ATTRIBUTE_PURE
size_t num_useful_states(const Aut &a)
Number of accessible states, not counting pre() and post().
automaton coaccessible(const automaton &aut)
std::set< T, Compare, Alloc > intersection(const std::set< T, Compare, Alloc > &set1, const std::set< T, Compare, Alloc > &set2)
The intersection of two sets.
Aut transpose(const transpose_automaton< Aut > &aut)
bool is_accessible(const automaton &aut)
bool is_coaccessible(const automaton &aut)
bool is_accessible(const Aut &a)
size_t num_coaccessible_states(const Aut &a)
Number of accessible states, not counting pre() and post().
states_t< Aut > coaccessible_states(const Aut &a)
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
bool is_coaccessible(const Aut &a)
filter_automaton< Aut > accessible(const Aut &a)
automaton trim(const automaton &aut)
bool has(const std::map< Key, Value, Compare, Alloc > &s, const Key &e)
filter_automaton< Aut > filter(const Aut &aut, const std::unordered_set< state_t_of< Aut >> &ss)
Get an automaton who is a part state set ss of aut.