00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
00100
00101
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