00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _ISET_CAN_CODE_
00021 #define _ISET_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<ISET_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 inline
00079 void insert_vertex(const vertex_t& v) {
00080 _c_code = id_generator--;
00081 }
00082
00086 STORAGE_TYPE getCode() const {
00087 return _c_code;
00088 }
00089
00090 void update_code() {}
00091
00092
00093 private:
00094 STORAGE_TYPE _c_code;
00095 static int id_generator;
00096 static map<vertex_t, int> len1_pat_map;
00097 static int init_counter;
00098 };
00099
00100
00101
00102
00103 template<class PP, typename v, typename e, template <typename> class ALLOC >
00104 int canonical_code<ISET_PROP, v, e, ALLOC>::id_generator = -1;
00105
00106 template<class PP, typename v, typename e, template <typename> class ALLOC >
00107 int canonical_code<ISET_PROP, v, e, ALLOC>::init_counter = 1;
00108
00109 template<class PP, typename v, typename e, template <typename> class ALLOC >
00110 map<v, int> canonical_code<ISET_PROP, v, e, ALLOC >::len1_pat_map;
00111
00112 #endif