public FPTreeNode insertChild(int column, int count) { if (FirstChild == null) { FirstChild = new FPTreeNode(column, count, this); return(FirstChild); } else { FPTreeNode child = FirstChild; while ((column != child.Column) && child.Brother != null) { child = child.Brother; } if (child.Column == column) { child.Count += count; } else { child.Brother = new FPTreeNode(column, count, this); child = child.Brother; } return(child); } }
private FPTreeNode insert(FPTreeNode parent, int column, int count) { FPTreeNode child = parent.insertChild(column, count); add2Header(child); return(child); }
public FPTreeNode insertChild(int column, int count) { if (FirstChild == null) { FirstChild = new FPTreeNode(column, count, this); return FirstChild; } else { FPTreeNode child = FirstChild; while ((column != child.Column) && child.Brother != null) { child = child.Brother; } if (child.Column == column) { child.Count += count; } else { child.Brother = new FPTreeNode(column, count, this); child = child.Brother; } return child; } }
private FPTree getPatternsAndTree(FPTree tree, int column) { FPTree result = new FPTree(); if (tree.header.ContainsKey(column)) { result.root.Count = 0; FPTreeNode colNode = tree.header[column]; while (colNode != null) { // get a path int count = colNode.Count; result.root.Count += count; ArrayList reversePath = new ArrayList(); FPTreeNode current = colNode.Parent; while (current.Column != -1) { reversePath.Add(current.Column); current = current.Parent; } int[] path = new int[reversePath.Count]; for (int i = 0; i < path.Length; ++i) { path[i] = (int)reversePath[path.Length - 1 - i]; } result.insert(path, count); colNode = colNode.ColumnBrother; } } return(result); }
public void insert(int[] record, int count) { FPTreeNode current = root; for (int i = 0; i < record.Length; ++i) { current = insert(current, record[i], count); } }
private void add2Header(FPTreeNode node) { if (header.ContainsKey(node.Column)) { FPTreeNode current = header[node.Column]; while (current.ColumnBrother != null && current != node) { current = current.ColumnBrother; } if(current != node){ current.ColumnBrother = node; } } else { header.Add(node.Column, node); } }
private void add2Header(FPTreeNode node) { if (header.ContainsKey(node.Column)) { FPTreeNode current = header[node.Column]; while (current.ColumnBrother != null && current != node) { current = current.ColumnBrother; } if (current != node) { current.ColumnBrother = node; } } else { header.Add(node.Column, node); } }
private ArrayList nodeToList(FPTreeNode node) { ArrayList result = new ArrayList(); String[] array = new String[4] { node.GetHashCode() + "", node.Column >= 0 ? colNames[node.Column] : "Root", (node.Parent == null)? "": node.Parent.GetHashCode() + "", "Count: " + node.Count }; result.Add(array); FPTreeNode child = node.FirstChild; while (child != null) { result.AddRange(nodeToList(child)); child = child.Brother; } return(result); }
public FPTree() { root = new FPTreeNode(-1, -1, null); header = new Dictionary <int, FPTreeNode>(); }
public FPTreeNode(int column, int count, FPTreeNode parent) { this.Column = column; this.Count = count; this.Parent = parent; }
public FPTreeNode(int column, int count, FPTreeNode parent) { this.Column = column; this.Count = count; this.Parent = parent; }
private ArrayList nodeToList(FPTreeNode node) { ArrayList result = new ArrayList(); String[] array = new String[4]{ node.GetHashCode() + "", node.Column >= 0 ? colNames[node.Column] : "Root", (node.Parent == null)? "": node.Parent.GetHashCode()+"", "Count: " + node.Count }; result.Add(array); FPTreeNode child = node.FirstChild; while (child != null) { result.AddRange(nodeToList(child)); child = child.Brother; } return result; }
private FPTreeNode insert(FPTreeNode parent, int column, int count) { FPTreeNode child = parent.insertChild(column, count); add2Header(child); return child; }
public FPTree() { root = new FPTreeNode(-1, -1, null); header = new Dictionary<int, FPTreeNode>(); }