/// <summary> /// extension a itemset, we pick up the node's SIL, and its right borther's SIL, we do IStep and if its support bigger than minSupport /// we neet to merge the itemset of the node whit the item in the last position of the node's right brother's itemset /// then we insert the new itemset into the itemset tree with the position /// we store all the itemset in the DataSet's ItemSILDic /// </summary> /// <param name="itemsetTree"></param> /// <param name="node"></param> private void ItemsetExtension(ItemsetTree <string> itemsetTree, ItemsetNode <string> node) { var position = 0; var children = node.Parent.GetChildren; for (int i = node.Position + 1; i < children.Count; i++) { var rightBrother = children[i]; // var rightBrotherLastItem = rightBrother.Itemset.Last(); // var nodeLastItem = node.Itemset.Last(); // if (!DataSet.CMapIExtension.ContainsKey(nodeLastItem) || !DataSet.CMapIExtension[nodeLastItem].ContainsKey(rightBrotherLastItem)) // { // continue; // } var SIL = SparseIdList.IStep(node.SparseIdList, rightBrother.SparseIdList); if (SIL.Support >= DataSet.MinSupport) { var newItemset = node.Itemset.Clone(); newItemset.AddItems(rightBrother.Itemset.Last()); DataSet.GetItemSILDic().Add(newItemset.Display(), SIL); itemsetTree.AddChild(node, newItemset, SIL, position); position++; } } }
/// <summary> /// use a queue to pick up all the itemset node and do extension /// </summary> private void ItemsetExtension() { ItemsetTree = new ItemsetTree <string>(); var root = ItemsetTree.GetRoot; var queue = new Queue <ItemsetNode <string> >(); var position = 0; ItemsetNode <string> node; // first insert all the item in the itemset tree as the children of the root's children foreach (var item in DataSet.GetItemSILDic()) { node = ItemsetTree.AddChild(root, new Itemset <string>(item.Key), item.Value, position++); queue.Enqueue(node); } // then pick up every node of the root node'children do the extension while (queue.Count != 0) { node = queue.Dequeue(); ItemsetExtension(ItemsetTree, node); foreach (var child in node.GetChildren) { queue.Enqueue(child); } } }