mset_can_code.h

00001 /*
00002  *  Copyright (C) 2005 M.J. Zaki <zaki@cs.rpi.edu> Rensselaer Polytechnic Institute
00003  *  Written by parimi@cs.rpi.edu
00004  *  Updated by chaojv@cs.rpi.edu, alhasan@cs.rpi.edu, salems@cs.rpi.edu
00005  *
00006  *  This program is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU General Public License
00008  *  as published by the Free Software Foundation; either version 2
00009  *  of the License, or (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00019  */
00020 #ifndef _MSET_CAN_CODE_
00021 #define _MSET_CAN_CODE_
00022 
00023 #include<sstream>
00024 #include<string>
00025 #include<map>
00026 
00027 #include "helper_funs.h"
00028 #include "typedefs.h"
00029 #include "generic_classes.h"
00030 
00031 using namespace std;
00032 
00033 
00040 template<class PP, typename vertex_t, typename edge_t, 
00041          template <typename> class ALLOC >
00042 class canonical_code<MSET_PROP, vertex_t, edge_t, ALLOC > 
00043 {
00044  public:
00045   
00046   typedef int STORAGE_TYPE;
00047   typedef vertex_t INIT_TYPE;
00048   typedef eqint COMPARISON_FUNC;
00049   
00050   canonical_code() {}
00051   
00060   template<class PAT>
00061     void init(INIT_TYPE v, PAT* pat) {
00062     
00063     typename map<vertex_t, int>::iterator i;
00064     i = len1_pat_map.find(v);
00065     
00066     if(i != len1_pat_map.end())
00067       _c_code = i->second;
00068     else {
00069       len1_pat_map[v] = init_counter;
00070       _c_code = init_counter++;
00071     }
00072   }
00073 
00078   void insert_vertex(const vertex_t& v) {
00079     _c_code = id_generator--; 
00080   }
00081   
00085   STORAGE_TYPE getCode() const {
00086     return _c_code;
00087   }
00088   
00089   void update_code() {}
00090   
00091   
00092  private:
00093   STORAGE_TYPE _c_code;
00094   static int id_generator;
00095   static map<vertex_t, int> len1_pat_map;
00096   static int init_counter;
00097 };
00098 
00099 // Setting it to -1 since for level-1 the _c_code should be 
00100 // same as the vertex id. Beyond level-1 the id gets assigned 
00101 // from the id_generator.
00102 template<class PP, typename v, typename e, template <typename> class ALLOC >
00103 int canonical_code<MSET_PROP, v, e, ALLOC>::id_generator = -1;
00104 
00105 template<class PP, typename v, typename e, template <typename> class ALLOC >
00106 int canonical_code<MSET_PROP, v, e, ALLOC>::init_counter = 1;
00107 
00108 template<class PP, typename v, typename e, template <typename> class ALLOC >
00109 map<v, int> canonical_code<MSET_PROP, v, e, ALLOC>::len1_pat_map;
00110 
00111 #endif

Generated on Wed Jul 26 14:01:08 2006 for DMTL by  doxygen 1.4.7