17 #ifndef VCSN_ALGORITHMS_ACCESSIBLE_HXX
18 # define VCSN_ALGORITHMS_ACCESSIBLE_HXX
22 # include <vaucanson/automata/concept/automata_base.hh>
23 # include <vaucanson/automata/implementation/transpose_view.hh>
25 # include <vaucanson/misc/usual_macros.hh>
37 template <
class A,
typename AI>
38 std::set<typename Element<A, AI>::hstate_t>
39 do_accessible_states(
const AutomataBase<A>&,
40 const Element<A, AI>& a)
42 typedef Element<A, AI> auto_t;
43 AUTOMATON_TYPES(auto_t);
44 typedef std::set<hstate_t> state_set_t;
46 std::queue<hstate_t> queue;
47 state_set_t reachable_states;
52 for_all_const_initial_states(i, a)
55 reachable_states.insert(*i);
61 while (!queue.empty())
63 hstate_t state = queue.front();
65 state_set_t delta_ret;
66 for (delta_iterator j(a.value(), state); ! j.done(); j.next())
67 delta_ret.insert(a.dst_of(*j));
68 for_all_const_(state_set_t, j, delta_ret)
71 if (reachable_states.find(state) == reachable_states.end())
73 reachable_states.insert(state);
78 return reachable_states;
81 template<
typename A,
typename AI>
82 std::set<typename Element<A, AI>::hstate_t>
85 BENCH_TASK_SCOPED(
"accessible_states");
86 return do_accessible_states(a.
structure(), a);
89 template<
typename A,
typename AI>
96 template<
typename A,
typename AI>
107 template <
class A,
typename AI>
108 std::set<typename Element<A, AI>::hstate_t>
109 do_coaccessible_states(
const AutomataBase<A>&,
110 const Element<A, AI>& a)
115 template<
typename A,
typename AI>
116 std::set<typename Element<A, AI>::hstate_t>
119 return do_coaccessible_states(a.
structure(), a);
122 template<
typename A,
typename AI>
129 template<
typename A,
typename AI>
138 #endif // ! VCSN_ALGORITHMS_ACCESSIBLE_HXX