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); } } }
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); } }
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); }
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); } }
public FPTree() { mRoot = new FPTreeNode <T>(); }
public bool RemoveChild(FPTreeNode <T> node) { return(mChildren.Remove(node)); }
public void AddChild(FPTreeNode <T> node) { node.Parent = this; mChildren.Add(node); }