00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _MSET_CAND_GEN_H_
00021 #define _MSET_CAND_GEN_H_
00022
00023 #include "pattern.h"
00024 #include "count_support.h"
00025 #include "mset_iso_check.h"
00026 #include "mset_vat.h"
00027 #include "typedefs.h"
00028
00029 extern unsigned long int freq_pats_count;
00030 extern bool print;
00031
00050 template<class PP, class MP, class PAT_ST, template<typename, typename, typename, template <typename> class> class CC,
00051 template <typename> class ALLOC, class SM_TYPE>
00052 void cand_gen(const pat_fam<MSET_PATTERN>& Fk_one, const pat_fam<MSET_PATTERN>& Fk_two, int minsup,
00053 count_support<MSET_PROP, V_Fkk_MINE_PROP, PAT_ST, CC, ALLOC, SM_TYPE >& cnt_sup, pat_fam<MSET_PATTERN>& freq_pats) {
00054
00055 typedef pat_fam<MSET_PATTERN> PAT_FAM;
00056 typedef typename PAT_FAM::CONST_IT PF_CIT;
00057
00058 PF_CIT it_i, it_j;
00059 int num_cands = 1;
00060
00061 for(it_i=Fk_one.begin(); it_i!=Fk_one.end(); it_i++) {
00062
00063 PAT_FAM pat_fam_i;
00064 MSET_PATTERN* pat_i=*it_i;
00065
00066 for(it_j=it_i; it_j!=Fk_one.end(); it_j++) {
00067
00068 MSET_PATTERN* pat_j=*it_j;
00069
00070
00071
00072
00073 MSET_PATTERN** cand_pats = join(pat_i, pat_j);
00074
00075
00076 check_isomorphism(cand_pats[0]);
00077
00078
00079 cnt_sup.count(pat_i, pat_j, cand_pats, minsup, num_cands);
00080
00081
00082
00083
00084 if(!cand_pats[0]->is_freq(minsup)) {
00085 delete cand_pats[0];
00086 } else {
00087
00088 pat_fam_i.push_back(cand_pats[0]);
00089
00090
00091
00092 freq_pats_count++;
00093 if(print)
00094 cout << cand_pats[0];
00095 }
00096
00097 delete[] cand_pats;
00098 }
00099
00100 cnt_sup.delete_vat(*it_i);
00101
00102
00103 if(!pat_fam_i.empty()) {
00104 cand_gen(pat_fam_i, pat_fam_i, minsup, cnt_sup, freq_pats);
00105
00106
00107
00108 pat_fam_i.clear();
00109 }
00110
00111 }
00112
00113 }
00114
00131 template<class PP, class MP, class PAT_ST, template<typename, typename, typename, template <typename> class> class CC,
00132 template <typename> class ALLOC >
00133 MSET_PATTERN** join(const MSET_PATTERN* pat_i, MSET_PATTERN* pat_j) {
00134
00135 MSET_PATTERN** cand_pats=new MSET_PATTERN*[1];
00136
00137
00138
00139 cand_pats[0] = pat_i->clone();
00140 const typename MSET_PATTERN::VERTEX_T& rmv = pat_j->rmost_vertex();
00141 cand_pats[0]->add_vertex(rmv);
00142
00143 return cand_pats;
00144 }
00145
00146 #endif