pat_support.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 /*
00021  *  Copyright (C) 2005 M.J. Zaki <zaki@cs.rpi.edu> Rensselaer Polytechnic Institute
00022  *  Written by parimi@cs.rpi.edu
00023  *  Updated by chaojv@cs.rpi.edu, alhasan@cs.rpi.edu, salems@cs.rpi.edu
00024  *
00025  *  This program is free software; you can redistribute it and/or
00026  *  modify it under the terms of the GNU General Public License
00027  *  as published by the Free Software Foundation; either version 2
00028  *  of the License, or (at your option) any later version.
00029  *
00030  *  This program is distributed in the hope that it will be useful,
00031  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00032  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00033  *  GNU General Public License for more details.
00034  *
00035  *  You should have received a copy of the GNU General Public License along
00036  *  with this program; if not, write to the Free Software Foundation, Inc.,
00037  *  59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00038  */
00039 #ifndef _PATTERN_SUPPORT_H_
00040 #define _PATTERN_SUPPORT_H_
00041 
00042 #include <iostream>
00043 #include "properties.h"
00044 
00045 // frequency is an indicator of whether the pattern is frequent 
00046 // for its definition
00047 
00048 // validity of a pattern is an indicator of whether it should be stored for 
00049 // sake of completion of candidate generation. All frequent patterns shall be 
00050 // valid but vice versa does not hold true for Fk_Fk induced/unordered mining
00051 
00052 template<class MP>
00053 class pattern_support;
00054 
00055 template<class MP>
00056 std::ostream& operator<< (std::ostream&, const pattern_support<MP>&);
00057 
00058 
00064 template<class MP>
00065 class pattern_support
00066 {
00067 
00068 public:
00069   //constructor
00070   inline
00071   pattern_support(const int& s=0, bool v=0): _sup(s), _valid(v) {}
00072 
00073   inline
00074   bool is_valid(const int& minsup) const {return _sup>=minsup;}
00075   
00076   inline
00077   bool is_freq(const int& ms) const {return _sup>=ms;}
00078   
00079   // parimi: commented out b'cos it is not clear what it should do
00080   int get_sup() const { return _sup;}
00081 
00082   void set_vals(const pattern_support<MP>* s) {_sup=s->_sup; _valid=s->_valid;}
00083 
00084   void set_sup(const std::pair<int,int>& s) { 
00085      // Ignore the second element in the pair - used for induced mining.
00086      _sup=s.first;
00087   }
00088 
00089   // friend extraction
00090   friend std::ostream& operator<< <>(std::ostream&, const pattern_support<MP>&);
00091 
00092   // NOTE: validity and frequency are synonymous for generic patterns
00093 
00094  private:
00095   int _sup;
00096   bool _valid;
00097 
00098 };//end class pattern_support
00099 
00100 
00101 template<typename MP>
00102 std::ostream& operator<< (std::ostream& ostr, const pattern_support<MP>& ps) {
00103   ostr<<"Support: "<<ps._sup<<std::endl;
00104   return ostr;
00105 }
00106 
00107 template<class T>
00108 std::ostream& operator<< (std::ostream& ostr, const pattern_support<proplist<Fk_Fk, 
00109               proplist<vert_mine, proplist<induced, T > > > >& ps) {
00110 
00111   //ostr<<"Support: "<<ps._isup << " (" << ps._esup << " )" << std::endl;
00112   ostr<<"Support: "<<ps._isup << std::endl;
00113   return ostr;
00114 }
00115 
00120 template<class T>
00121 class pattern_support<proplist<Fk_Fk, proplist<vert_mine, proplist<induced, T > > > >
00122 {
00123 
00124 public:
00125   //constructor
00126   pattern_support(const int& is=0, const int& s=0, bool v=0): _isup(is), _esup(s) {}
00127 
00128   bool is_valid(const int& minsup) const {
00129     return (_isup>=minsup || (_esup>=minsup));
00130   }
00131 
00132   bool is_freq(const int& minsup) const { 
00133      return _isup >= minsup;
00134   }
00135 
00136   int get_sup() const { return _isup;}
00137 
00138   void incr_isup() { _isup++;}
00139 
00140   void incr_esup() { _esup++;}
00141 
00142   void set_vals(const pattern_support<proplist<Fk_Fk, proplist<vert_mine, proplist<induced, T> > > >* const& s) {
00143     _esup=s->_esup; _isup=s->_isup;
00144   }
00145 
00146   void set_sup(const std::pair<int, int>& s) {
00147     _isup=s.first;
00148     _esup = s.second;
00149   }
00150 
00151   // friend extraction
00152   friend std::ostream& operator<< <>(std::ostream&, const pattern_support<proplist<Fk_Fk, proplist<vert_mine, proplist<induced, T > > > >&);
00153 
00154  private:
00155   int _isup; //induced support
00156   int _esup; //ONLY embedded support
00157 }; //end pattern_support for induced
00158 
00159 #endif

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