示例#1
0
文件: FPTree.cs 项目: 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);
                }
            }
        }
示例#2
0
文件: FPTree.cs 项目: 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);
            }
        }
示例#3
0
文件: FPTreeNode.cs 项目: 3enter/FPG
        public ItemSet <T> GetPath()
        {
            ItemSet <T>    path = new ItemSet <T>();
            FPTreeNode <T> x    = this;

            while (x != null)
            {
                if (!x.IsRoot)
                {
                    path.Add(x.Item);
                }
                x = x.Parent;
            }

            return(path);
        }
示例#4
0
文件: FPTree.cs 项目: 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);
     }
 }
示例#5
0
文件: FPTree.cs 项目: 3enter/FPG
 public FPTree()
 {
     mRoot = new FPTreeNode <T>();
 }
示例#6
0
文件: FPTreeNode.cs 项目: 3enter/FPG
 public bool RemoveChild(FPTreeNode <T> node)
 {
     return(mChildren.Remove(node));
 }
示例#7
0
文件: FPTreeNode.cs 项目: 3enter/FPG
 public void AddChild(FPTreeNode <T> node)
 {
     node.Parent = this;
     mChildren.Add(node);
 }