예제 #1
0
        /// <summary>
        /// this function used to do item extension , you provide two SIL about item a and b ,it return a SIL about (ab)
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static SparseIdList IStep(SparseIdList a, SparseIdList b)
        {
            SparseIdList sparseIdList = new SparseIdList(a.GetLength());
            ListNode     aNode, bNode;

            for (int i = 0; i < a.GetLength(); i++)
            {
                aNode = a.GetElement(i, 0);
                bNode = b.GetElement(i, 0);
                while ((aNode != null) && (bNode != null))
                {
                    if (aNode.GetSparseId == bNode.GetSparseId)
                    {
                        sparseIdList.AddElement(i, aNode.GetSparseId);
                        aNode = aNode.GetNext;
                        bNode = bNode.GetNext;
                    }
                    else if (aNode.GetSparseId > bNode.GetSparseId)
                    {
                        bNode = bNode.GetNext;
                    }
                    else
                    {
                        aNode = aNode.GetNext;
                    }
                }
            }

            return(sparseIdList);
        }
예제 #2
0
        /// <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++;
                }
            }
        }