8 #include <vcsn/dyn/fwd.hh> 19 template <Automaton Aut>
20 using states_t = std::unordered_set<state_t_of<Aut>>;
26 template <Automaton Aut>
30 using automaton_t = Aut;
37 auto todo = std::queue<state_t>{};
38 todo.emplace(aut->pre());
41 = getenv(
"VCSN_CREDIT")
42 ? std::stoul(getenv(
"VCSN_CREDIT"))
43 : std::numeric_limits<unsigned>::max();
46 const state_t src = todo.front();
49 if (strict || !aut->is_lazy(src))
50 for (
auto tr :
all_out(aut, src))
52 state_t dst = aut->dst_of(tr);
54 if (
res.emplace(dst).second && credit--)
66 template <Automaton Aut>
77 template <Automaton Aut>
92 template <Automaton Aut>
97 size_t res =
set.size();
101 if (
has(
set, a->post()))
107 template <Automaton Aut>
115 template <Automaton Aut>
120 size_t res =
set.size();
122 if (
has(
set, a->pre()))
125 if (
has(
set, a->post()))
136 template <Automaton Aut>
144 template <Automaton Aut>
152 template <Automaton Aut>
164 template <Automaton Aut>
171 template <Automaton Aut>
178 template <Automaton Aut>
185 template <Automaton Aut>
191 template <Automaton Aut>
192 bool is_empty(
const Aut& a) ATTRIBUTE_PURE;
195 template <Automaton Aut>
200 return a->num_states() == 0;
208 template <Automaton Aut>
212 const auto& a = aut->
as<Aut>();
217 template <Automaton Aut>
221 const auto& a = aut->
as<Aut>();
226 template <Automaton Aut>
230 const auto& a = aut->
as<Aut>();
235 template <Automaton Aut>
239 const auto& a = aut->
as<Aut>();
244 template <Automaton Aut>
248 const auto& a = aut->
as<Aut>();
253 template <Automaton Aut>
257 const auto& a = aut->
as<Aut>();
262 template <Automaton Aut>
266 const auto& a = aut->
as<Aut>();
271 template <Automaton Aut>
275 const auto& a = aut->
as<Aut>();
Aut transpose(const transpose_automaton< Aut > &aut)
The transpose of a transpose automaton is the original automaton.
bool is_empty(const automaton &aut)
Bridge.
bool is_coaccessible(const Aut &a)
Whether all its states are coaccessible.
ATTRIBUTE_PURE bool has(const boost::container::flat_set< Key, Compare, Allocator > &s, const Key &e)
Whether e is member of s.
states_t< Aut > useful_states(const Aut &a, bool strict=true)
The set of useful states, including possibly pre() and post().
typename detail::state_t_of_impl< base_t< ValueSet > >::type state_t_of
bool is_useless(const automaton &aut)
Bridge.
size_t num_useful_states(const Aut &a)
Number of accessible states, not counting pre() and post().
automaton trim(const automaton &aut)
Bridge.
bool is_coaccessible(const automaton &aut)
Bridge.
auto all_out(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions leaving state s.
filter_automaton< Aut > trim(const Aut &a)
Useful part of an automaton.
std::shared_ptr< detail::filter_automaton_impl< Aut, Trans > > filter_automaton
bool is_useless(const Aut &a)
Whether all no state is useful.
automaton accessible(const automaton &aut)
Bridge.
bool is_empty(const Aut &a) ATTRIBUTE_PURE
Whether has no states.
filter_automaton< Aut > accessible(const Aut &a)
Accessible part of an automaton.
Container set_intersection(const Container &s1, const Container &s2)
The intersection of two sets.
filter_automaton< Aut > coaccessible(const Aut &a)
Coaccessible part of an automaton.
std::unordered_set< state_t_of< Aut > > states_t
states_t< Aut > accessible_states(const Aut &aut, bool strict=true)
The set of accessible states, including pre(), and possibly post().
auto & as()
Extract wrapped typed automaton.
bool is_accessible(const automaton &aut)
Bridge.
size_t num_accessible_states(const Aut &a)
Number of accessible states, not counting pre() and post().
size_t num_coaccessible_states(const Aut &a)
Number of accessible states, not counting pre() and post().
bool is_trim(const automaton &aut)
Bridge.
states_t< Aut > coaccessible_states(const Aut &a, bool strict=true)
The set of coaccessible states, including post(), and possibly pre().
bool is_accessible(const Aut &a)
Whether all its states are accessible.
bool is_trim(const Aut &a)
Whether all its states are useful.
filter_automaton< Aut, Trans > filter(const Aut &aut, boost::optional< dynamic_bitset > ss={}, boost::optional< dynamic_bitset > ts={})
Build a filtered view of an automaton.
automaton coaccessible(const automaton &aut)
Bridge.