Exemplo n.º 1
0
Arquivo: FPTree.cs Projeto: 3enter/FPG
        protected void Append(FPTreeNode <T> node, List <T> orderedFreqItems, int d)
        {
            int selectedIndex = -1;

            for (int i = 0; i < node.ChildCount; ++i)
            {
                if (node.GetChild(i).Item.Equals(orderedFreqItems[d]))
                {
                    selectedIndex = i;
                    break;
                }
            }

            if (selectedIndex != -1)
            {
                node.GetChild(selectedIndex).Count++;
                if (d < orderedFreqItems.Count - 1)
                {
                    Append(node.GetChild(selectedIndex), orderedFreqItems, d + 1);
                }
            }
            else
            {
                FPTreeNode <T> child = new FPTreeNode <T>();
                child.Item  = orderedFreqItems[d];
                child.Count = 1;
                node.AddChild(child);
                if (d < orderedFreqItems.Count - 1)
                {
                    Append(child, orderedFreqItems, d + 1);
                }
            }
        }
Exemplo n.º 2
0
Arquivo: FPTree.cs Projeto: 3enter/FPG
        protected void RemoveFromLeaves(FPTreeNode <T> node, T item)
        {
            if (node.IsLeaf)
            {
                if (node.Item.Equals(item))
                {
                    node.Parent.RemoveChild(node);
                }
                return;
            }

            for (int i = 0; i < node.ChildCount; ++i)
            {
                RemoveFromLeaves(node.GetChild(i), item);
            }
        }
Exemplo n.º 3
0
Arquivo: FPTree.cs Projeto: 3enter/FPG
 protected void MinePatternsContaining(FPTreeNode <T> node, List <ItemSet <T> > selection, T targetItem, double minSupport)
 {
     if (node.IsLeaf)
     {
         if (node.Item.Equals(targetItem) && node.Count >= minSupport * mDbSize)
         {
             ItemSet <T> fis = new ItemSet <T>();
             fis = node.GetPath();
             fis.TransactionCount = node.Count;
             fis.DbSize           = mDbSize;
             selection.Add(fis);
         }
         return;
     }
     for (int i = 0; i < node.ChildCount; ++i)
     {
         MinePatternsContaining(node.GetChild(i), selection, targetItem, minSupport);
     }
 }