Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

Trie.hpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           trie.h  -  description
00003                              -------------------
00004     begin                : cs dec 26 2002
00005     copyright            : (C) 2002 by Ferenc Bodon
00006     email                : bodon@mit.bme.hu
00007  ***************************************************************************/
00008 
00009 #ifndef TRIE_H
00010 #define TRIE_H
00011 
00016 typedef unsigned long itemtype;
00017 //typedef unsigned short itemtype;
00018 
00019 #include <fstream>
00020 #include <iostream>
00021 #include <set>
00022 #include <vector>
00023 #include <cstdio>
00024 using namespace std;
00025 
00034 class Trie
00035 {
00036 
00037 public:
00038 
00039    Trie();
00040 
00042    void candidate_generation( const itemtype& frequent_size );
00043 
00045    void find_candidate( const vector<itemtype>& basket, const itemtype candidate_size, const unsigned long counter=1 );
00046 
00048    void delete_infrequent( const unsigned long min_occurrence );
00049 
00051    void association( ofstream& outcomefile, const double min_conf ) const;
00052 
00054    void basket_recode( vector<itemtype>& basket ) const;
00055 
00057    unsigned long node_number() const;
00058 
00060    virtual void statistics() const;
00061 
00063    void write_content_to_file( ofstream& outcomefile ) const;
00064 
00066    virtual void show_content() const;
00067 
00068    virtual ~Trie();
00069 
00070 protected:
00071 
00073    virtual void max_path_set( const unsigned long state_index );
00074 
00076    virtual void delete_edge( const unsigned long from_state, const unsigned long to_state );
00077 
00079    virtual void add_empty_state( const unsigned long from_state, const itemtype item, const unsigned long counter=0 );
00080 
00082    virtual unsigned long is_included( const set<itemtype>& an_itemset ) const;
00083 
00085    bool is_all_subset_frequent( const set<itemtype>& maybe_candidate ) const;
00086 
00088    void candidate_generation_two();
00089 
00091    virtual void candidate_generation_assist( unsigned long actual_state, const itemtype frequent_size,
00092                                              const itemtype actual_sizet, set<itemtype>& maybe_candidate );
00093 
00095    void find_candidate_one( const vector<itemtype>& basket );
00096 
00098    void find_candidate_two( const vector<itemtype>& basket, const unsigned long counter=1 );
00099 
00101    virtual void find_candidate_more( const vector<itemtype>& basket, const itemtype candidate_size,
00102                                      vector<itemtype>::const_iterator it_basket, const unsigned long actual_state,
00103                                      const itemtype actual_size, const unsigned long counter=1 );
00104 
00106    virtual void delete_infrequent_one( const unsigned long min_occurrence );
00107 
00109    virtual void delete_infrequent_two( const unsigned long min_occurrence );
00110 
00112    virtual void delete_infrequent_more( const unsigned long min_occurrence );
00113 
00114    void assoc_rule_find( ofstream& outcomefile, const double min_conf, set<itemtype>& condition_part,
00115                          set<itemtype>& consequence_part, const unsigned long union_support) const;
00116 
00117    virtual void assoc_rule_assist( ofstream& outcomefile, const double min_conf,unsigned long actual_state,
00118                                    set<itemtype>& consequence_part) const;
00119 
00121    virtual void write_content_to_file_assist( ofstream& outcomefile, const unsigned long actual_state, const itemtype item_size,
00122                                               const itemtype actual_size,set<itemtype>& frequent_itemset) const;
00123 private:
00124    // No private methods
00125 
00126 public:
00127    // No public members
00128 
00129 protected:
00136    vector< vector<itemtype> > itemarray;
00137 
00143    vector< vector<unsigned long> > statearray;
00144 
00149     vector<unsigned long> countervector;
00150 
00151     vector<unsigned long> parent;
00152 
00157    vector< vector<unsigned long> > temp_counter_array;
00158 
00163   vector<itemtype> maxpath;
00164 
00169   vector<itemtype> orderarray;
00170 
00172   vector<itemtype> inv_orderarray;
00173 
00174 
00175 };
00176 
00177 #endif

Generated on Tue Dec 23 23:59:00 2003 for APRIORI algorithm by doxygen 1.3.4