public void NextStep() { // count running time var watch = System.Diagnostics.Stopwatch.StartNew(); // start Apriori apriori = GetItem(Count); List <ItemSet> c_List = AprioriGen(Count); if (c_List.Count == 0) { OnAprioriEnd.Invoke(this, new EventArgs()); EndFlag = true; // count running time watch.Stop(); Console.Out.WriteLine("AprioriSet NextStep:::{0}:::{1}", Count, watch.ElapsedMilliseconds); return; } Apriori aprioriNext = new Apriori(Count + 1); for (int i = 0; i < apriori.F_List.Count; i++) { F_Item f = new F_Item(); f.TID = apriori.F_List[i].TID; foreach (ItemSet clist in c_List) { if (ContainsList(apriori.F_List[i], clist, clist.Count - 1) && ContainsList(apriori.F_List[i], clist, clist.Count - 2)) //O(n^2) { clist.Support++; f.Add(clist); } } if (f.Count != 0) { aprioriNext.F_List.Add(f); } } for (int j = 0; j < c_List.Count; j++) //O(n) { if (c_List[j].Support >= Program.MinSupCount) { ItemSet item = new ItemSet(); item.Support = c_List[j].Support; item.AddRange(c_List[j]); aprioriNext.L_List.Add(item); } } Add(aprioriNext); // MessageBox.Show(aprioriNext.ToString(),"L"+Count,MessageBoxButtons.OK); // count running time watch.Stop(); Console.Out.WriteLine("AprioriSet NextStep:::{0}:::{1}", Count, watch.ElapsedMilliseconds); Program.file.WriteLine($"{Count}:{watch.ElapsedMilliseconds}"); }
public AprioriSet(GiaoTac_Table.GiaoTacTable giaoTacs) { // count running time var watch = System.Diagnostics.Stopwatch.StartNew(); // start Add(new Apriori(1)); for (int i = 0; i < giaoTacs.ColumnCount; i++) { this[0].L_List.Add(new ItemSet() { i + 1 }); } for (int i = 0; i < giaoTacs.Count; i++) { F_Item f_Item = new F_Item(); f_Item.TID = giaoTacs[i].MaSV; bool isZero = true; for (int j = 0; j < giaoTacs[i].Count; j++) { if (giaoTacs[i][j] == 1) { isZero = false; f_Item.Add(new List <int>() { j + 1 }); this[0].L_List[j].Support++; } } if (isZero) { continue; } this[0].F_List.Add(f_Item); } // count running time watch.Stop(); Console.Out.WriteLine("AprioriSet Constructor:::" + watch.ElapsedMilliseconds); }