📄 iset__cand__gen_8h-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>DMTL: iset_cand_gen.h Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"><link href="tabs.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.4.7 --><div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li id="current"><a href="files.html"><span>Files</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> </ul></div><h1>iset_cand_gen.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span><a name="l00002"></a>00002 <span class="comment"> * Copyright (C) 2005 M.J. Zaki <zaki@cs.rpi.edu> Rensselaer Polytechnic Institute</span><a name="l00003"></a>00003 <span class="comment"> * Written by parimi@cs.rpi.edu</span><a name="l00004"></a>00004 <span class="comment"> * Updated by chaojv@cs.rpi.edu, alhasan@cs.rpi.edu, salems@cs.rpi.edu</span><a name="l00005"></a>00005 <span class="comment"> *</span><a name="l00006"></a>00006 <span class="comment"> * This program is free software; you can redistribute it and/or</span><a name="l00007"></a>00007 <span class="comment"> * modify it under the terms of the GNU General Public License</span><a name="l00008"></a>00008 <span class="comment"> * as published by the Free Software Foundation; either version 2</span><a name="l00009"></a>00009 <span class="comment"> * of the License, or (at your option) any later version.</span><a name="l00010"></a>00010 <span class="comment"> *</span><a name="l00011"></a>00011 <span class="comment"> * This program is distributed in the hope that it will be useful,</span><a name="l00012"></a>00012 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><a name="l00013"></a>00013 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span><a name="l00014"></a>00014 <span class="comment"> * GNU General Public License for more details.</span><a name="l00015"></a>00015 <span class="comment"> *</span><a name="l00016"></a>00016 <span class="comment"> * You should have received a copy of the GNU General Public License along</span><a name="l00017"></a>00017 <span class="comment"> * with this program; if not, write to the Free Software Foundation, Inc.,</span><a name="l00018"></a>00018 <span class="comment"> * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.</span><a name="l00019"></a>00019 <span class="comment"> */</span><a name="l00020"></a>00020 <span class="preprocessor">#ifndef _ISET_CAND_GEN_H_</span><a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#define _ISET_CAND_GEN_H_</span><a name="l00022"></a>00022 <span class="preprocessor"></span><a name="l00023"></a>00023 <span class="preprocessor">#include "pattern.h"</span><a name="l00024"></a>00024 <span class="preprocessor">#include "count_support.h"</span><a name="l00025"></a>00025 <span class="preprocessor">#include "iset_iso_check.h"</span><a name="l00026"></a>00026 <span class="preprocessor">#include "iset_vat.h"</span><a name="l00027"></a>00027 <span class="preprocessor">#include "typedefs.h"</span><a name="l00028"></a>00028 <a name="l00029"></a>00029 <span class="keyword">extern</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> freq_pats_count;<a name="l00030"></a>00030 <span class="keyword">extern</span> <span class="keywordtype">bool</span> print;<a name="l00031"></a>00031 <a name="l00050"></a>00050 <span class="keyword">template</span><<span class="keyword">class </span>PP, <span class="keyword">class </span>MP, <span class="keyword">class </span>PAT_ST, <a name="l00051"></a>00051 <span class="keyword">template</span><<span class="keyword">class</span>, <span class="keyword">typename</span>, <span class="keyword">typename</span>, <span class="keyword">template</span> <<span class="keyword">typename</span>> <span class="keyword">class</span>> <span class="keyword">class </span>CC, <a name="l00052"></a>00052 template <typename> class ALLOC, class SM_TYPE><a name="l00053"></a>00053 void cand_gen(const <a class="code" href="classpat__fam.html">pat_fam</a><ISET_PATTERN>& Fk_one, <span class="keyword">const</span> <a class="code" href="classpat__fam.html">pat_fam<ISET_PATTERN></a>& Fk_two, <span class="keywordtype">int</span> minsup, <a name="l00054"></a>00054 <a class="code" href="classcount__support.html">count_support<ISET_PROP, V_Fkk_MINE_PROP, PAT_ST, CC, ALLOC, SM_TYPE ></a>& cnt_sup, <a class="code" href="classpat__fam.html">pat_fam<ISET_PATTERN></a>& freq_pats) {<a name="l00055"></a>00055 <a name="l00056"></a>00056 <span class="keyword">typedef</span> <a class="code" href="classpat__fam.html">pat_fam<ISET_PATTERN></a> PAT_FAM;<a name="l00057"></a>00057 <span class="keyword">typedef</span> <span class="keyword">typename</span> PAT_FAM::CONST_IT PF_CIT;<a name="l00058"></a>00058 <a name="l00059"></a>00059 PF_CIT it_i, it_j;<a name="l00060"></a>00060 <span class="keywordtype">int</span> num_cands = 1;<a name="l00061"></a>00061 <a name="l00062"></a>00062 <span class="keywordflow">for</span>(it_i=Fk_one.begin(); it_i!=Fk_one.end(); it_i++) {<a name="l00063"></a>00063 <a name="l00064"></a>00064 PAT_FAM pat_fam_i; <span class="comment">// new equivalent class </span><a name="l00065"></a>00065 ISET_PATTERN* pat_i=*it_i;<a name="l00066"></a>00066 <a name="l00067"></a>00067 <span class="keywordflow">for</span>(it_j=it_i+1; it_j!=Fk_one.end(); it_j++) {<a name="l00068"></a>00068 <a name="l00069"></a>00069 ISET_PATTERN* pat_j=*it_j;<a name="l00070"></a>00070 <a name="l00071"></a>00071 <span class="comment">// Generate candidates from equivalent class Fk_one.</span><a name="l00072"></a>00072 ISET_PATTERN** cand_pats = join(pat_i, pat_j);<a name="l00073"></a>00073 <a name="l00074"></a>00074 <span class="comment">// Isomorphism check, for itemset every candidate patterns pass the iso-check.</span><a name="l00075"></a>00075 check_isomorphism(cand_pats[0]);<a name="l00076"></a>00076 <a name="l00077"></a>00077 <span class="comment">// Count support of candidates, checking whether new patterns in cand_pats are frequent or not.</span><a name="l00078"></a>00078 cnt_sup.count(pat_i, pat_j, cand_pats, minsup, num_cands);<a name="l00079"></a>00079 <a name="l00080"></a>00080 <span class="comment">// Get rid of infrequent candidate. This is itemset</span><a name="l00081"></a>00081 <span class="comment">// so, we have only one candidate pattern.</span><a name="l00082"></a>00082 <span class="keywordflow">if</span>(!cand_pats[0]->is_freq(minsup)) {<a name="l00083"></a>00083 <span class="keyword">delete</span> cand_pats[0];<a name="l00084"></a>00084 } <span class="keywordflow">else</span> {<a name="l00085"></a>00085 <span class="comment">// pushing new and frequent candidates in new equivalent class pat_fam_i</span><a name="l00086"></a>00086 pat_fam_i.push_back(cand_pats[0]);<a name="l00087"></a>00087 <span class="comment">// pushing new and frequent candidates in freq_pats for output</span><a name="l00088"></a>00088 <span class="comment">//freq_pats.push_back(cand_pats[0]);</span><a name="l00089"></a>00089 <span class="comment">// number of frequent patterns increase by 1</span><a name="l00090"></a>00090 freq_pats_count++;<a name="l00091"></a>00091 <span class="keywordflow">if</span>(print)<a name="l00092"></a>00092 cout << cand_pats[0];<a name="l00093"></a>00093 }<a name="l00094"></a>00094 <span class="comment">// delete the array of pointers holding the cand_pats </span><a name="l00095"></a>00095 <span class="keyword">delete</span>[] cand_pats;<a name="l00096"></a>00096 }<a name="l00097"></a>00097 <a name="l00098"></a>00098 cnt_sup.delete_vat(*it_i);<a name="l00099"></a>00099 <a name="l00100"></a>00100 <span class="comment">// Recursively mine the new pattern family. Depth first pattern generation</span><a name="l00101"></a>00101 <span class="keywordflow">if</span>(!pat_fam_i.empty()) {<a name="l00102"></a>00102 cand_gen(pat_fam_i, pat_fam_i, minsup, cnt_sup, freq_pats);<a name="l00103"></a>00103 <a name="l00104"></a>00104 <span class="comment">// Deleting individual elements (which are pointers) in the vector. </span><a name="l00105"></a>00105 <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> c=0; c < pat_fam_i.size(); c++) {<a name="l00106"></a>00106 <span class="keyword">delete</span> pat_fam_i[c];<a name="l00107"></a>00107 }<a name="l00108"></a>00108 <a name="l00109"></a>00109 <span class="comment">// Deleting the pat_fam_i after the recursion calls processed all its</span><a name="l00110"></a>00110 <span class="comment">// descendent patterns.</span><a name="l00111"></a>00111 pat_fam_i.clear();<a name="l00112"></a>00112 }<a name="l00113"></a>00113 <a name="l00114"></a>00114 } <span class="comment">//end for i</span><a name="l00115"></a>00115 <a name="l00116"></a>00116 } <span class="comment">//end cand_gen()</span><a name="l00117"></a>00117 <a name="l00134"></a>00134 <span class="keyword">template</span><<span class="keyword">class </span>PP, <span class="keyword">class </span>MP, <span class="keyword">class </span>PAT_ST, <a name="l00135"></a>00135 <span class="keyword">template</span><<span class="keyword">class</span>, <span class="keyword">typename</span>, <span class="keyword">typename</span>, <span class="keyword">template</span> <<span class="keyword">typename</span>> <span class="keyword">class</span>> <span class="keyword">class </span>CC, <a name="l00136"></a>00136 template <typename> class ALLOC ><a name="l00137"></a>00137 ISET_PATTERN** join(<span class="keyword">const</span> ISET_PATTERN* pat_i, ISET_PATTERN* pat_j) {<a name="l00138"></a>00138 <a name="l00139"></a>00139 ISET_PATTERN** cand_pats=<span class="keyword">new</span> ISET_PATTERN*[1]; <span class="comment">// an array of one element that holds pointer to a pattern</span><a name="l00140"></a>00140 <span class="comment">// this allocation of memory is released in cand_gen() routine</span><a name="l00141"></a>00141 <span class="comment">// after we either delete the candidate, if it is infrequent</span><a name="l00142"></a>00142 <span class="comment">// or store it in freq_pats data structure if it is frequent </span><a name="l00143"></a>00143 cand_pats[0] = pat_i->clone(); <a name="l00144"></a>00144 <span class="keyword">const</span> <span class="keyword">typename</span> ISET_PATTERN::VERTEX_T& rmv = pat_j->rmost_vertex();<a name="l00145"></a>00145 cand_pats[0]->add_vertex(rmv);<a name="l00146"></a>00146 <a name="l00147"></a>00147 <span class="keywordflow">return</span> cand_pats;<a name="l00148"></a>00148 }<a name="l00149"></a>00149 <a name="l00150"></a>00150 <span class="preprocessor">#endif</span></pre></div><hr size="1"><address style="align: right;"><small>Generated on Wed Jul 26 14:01:08 2006 for DMTL by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -