include/CompleteAutomaton.hpp

Go to the documentation of this file.
00001 // CompleteAutomaton.hpp: this file is part of the REGAL project.
00002 //
00003 // REGAL : Random and Exhaustive Generators for Automata - Library
00004 //
00005 // Copyright (C) 2008 Julien DAVID.
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 //
00016 #ifndef COMPLETEAUTOMATON_HPP
00017 #define COMPLETEAUTOMATON_HPP
00018 
00019 #include<iostream>
00020 
00021 
00022 
00023 namespace regal{
00024 
00025   template<typename StateLabel_t,typename Sigma,class Automaton_t=AbstractAutomaton<StateLabel_t,Sigma> >
00026   class CompleteAutomaton{
00027     
00028   public:
00029     static bool completeAutomaton(Automaton_t * a){
00030       int n=a->getSize(),i;
00031       StateLabel_t newState;
00032       bool incomplete=false;
00033       Alphabet<Sigma> al=a->getAlphabet();
00034       std::list<Sigma> listT=al.getList();
00035       for(i=0;i<n;i++){
00036         for(typename std::list<Sigma>::iterator l=listT.begin();l!=listT.end();l++){
00037           if(a->getArrivalState(a->getRealValue(i),*l)==a->undefinedTransition()){
00038             if(!incomplete){
00039               incomplete=true;
00040               newState=a->addState();
00041               for(typename std::list<Sigma>::iterator l2=listT.begin();l2!=listT.end();l2++)
00042                 a->addTransition(newState,newState,*l2);
00043             }
00044             a->addTransition(a->getRealValue(i),newState,*l);
00045           }
00046         }
00047       }
00048       return incomplete;
00049     }
00050 
00051   };
00052     
00053 }
00054 
00055 #endif

Generated on Mon Sep 29 16:33:58 2008 for REGAL by  doxygen 1.5.1