is_ambiguous.hxx

00001 // is_ambiguous.hxx: this file is part of the Vaucanson project.
00002 //
00003 // Vaucanson, a generic library for finite state machines.
00004 //
00005 // Copyright (C) 2006 The Vaucanson Group.
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // The complete GNU General Public Licence Notice can be found as the
00013 // `COPYING' file in the root directory.
00014 //
00015 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
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   | is_ambiguous |
00033   `-------------*/
00034   template <typename A_, typename Auto_>
00035   bool
00036   do_is_ambiguous(const AutomataBase<A_>&,
00037                   const Auto_&          aut)
00038   {
00039     // This map is used to know which state is created by which two ones.
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     return do_is_ambiguous(aut.structure(), aut);
00053   }
00054 
00055 } // End of namespace vcsn.
00056 
00057 #endif // ! VCSN_ALGORITHMS_IS_AMBIGUOUS_HXX

Generated on Sat Jul 29 17:13:00 2006 for Vaucanson by  doxygen 1.4.6