Commits

Anonymous committed 19aa453

All subsetting itemsets get generator variable rollbacked when the itemset is prunable

  • Participants
  • Parent commits ce50c4b

Comments (0)

Files changed (1)

File modules/algorithm/apriori/apriori.cc

                 }
                 else {
                     r_itemsets->append(iset);
-
                 }
                 ++s;
             } else break;
 
 void Apriori::apriori(IndexTransactions* transactions) {
     generate_1_itemsets(transactions);
-    LOG(DEBUG) << "Generated 1 itemsets";
+    LOG(DEBUG) << "Generated k=1 itemsets";
     int k=1;
     while(!sets.empty() && sets.back()->getsize()) {
         itemsets* ck = apriorigen(sets[k-1]);
 
     itemset *tmp_itemset, *subs;
     bool res = false;
+    
+    deque<itemset*> subset_rollback_list;
+    deque<bool>     bool_rollback_list;
+
     for(int j=0;j<s_subsets->getsize();++j) {
         tmp_itemset = s_subsets->getitem(j);
         if((subs = ref->find(tmp_itemset)) == NULL ) {
             res = true;
             break;
-        } else
+        } else {
+            subset_rollback_list.push_back(subs);
+            bool_rollback_list.push_back(subs->getgenerator());
             subs->setgenerator(true);
+        }
     }
+
+    /* check whether rollback is required or not */
+    if(res) {
+        bool val;
+        for(int j=0;j<subset_rollback_list.size();++j) {
+            val = bool_rollback_list[j];
+            subset_rollback_list[j]->setgenerator(val);
+        }
+    }
+
     s_subsets->clear();
     delete s_subsets;
     return res;