00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef VCSN_ALGORITHMS_IS_AMBIGUOUS_HXX
00019 # define VCSN_ALGORITHMS_IS_AMBIGUOUS_HXX
00020
00021 # include <vaucanson/algorithms/is_ambiguous.hh>
00022 # include <vaucanson/algorithms/trim.hh>
00023 # include <vaucanson/algorithms/product.hh>
00024 # include <vaucanson/misc/usual_macros.hh>
00025
00026 # include <map>
00027 # include <set>
00028
00029 namespace vcsn {
00030
00031
00032
00033
00034 template <typename A_, typename Auto_>
00035 bool
00036 do_is_ambiguous(const AutomataBase<A_>&,
00037 const Auto_& aut)
00038 {
00039
00040 std::map<hstate_t, std::pair<hstate_t, hstate_t> > m;
00041 const std::set<hstate_t>& s = useful_states (product (aut, aut, m));
00042 for_all_const (std::set<hstate_t>, i, s)
00043 if (m[*i].first != m[*i].second)
00044 return false;
00045 return true;
00046 }
00047
00048 template<typename A_, typename Auto_>
00049 bool
00050 is_ambiguous(const Element<A_, Auto_>& aut)
00051 {
00052 TIMER_SCOPED("is_ambiguous");
00053 return do_is_ambiguous(aut.structure(), aut);
00054 }
00055
00056 }
00057
00058 #endif // ! VCSN_ALGORITHMS_IS_AMBIGUOUS_HXX