|
Algorithm 1: The construction algorithm of new FP-tree. |
|
Input: Transaction database D, minimum support min_sup. In the process of constructing the FP-tree, the node-pre of each node is null, and the node-pre is assigned after the FP-tree is constructed. |
Output: FP-tree |
Process: |
Scan database D to get frequent 1-itemsets, sort them from large to small according to the support degree, and get the frequent item sequence FI1; |
Create a new FP-tree node, assign the value of the node_name to null, and use it as the root node T; |
Create FP-tree: call Create function |
Function Create() |
For each transaction in the database Ti do |
{Initialize the current pointer in the FP-tree to point to the root node T; |
Put the items in the transaction Ti that meet the minimum support count requirement into the queue Q in descending order of support count; |
For each item in the queue Q do |
FP-tree. Insert(I); //Insert I in the child of the node pointed to by the current pointer (if it exists, its counter will be incremented by 1) and move the current pointer to the node |
} |
Function Insert (char name)//Insert a node with an item named name into the FP-tree |
{if the node pointed to by the current pointer has no child nodes or there is no node whose node_name field is name in the child nodes |
Then |
{Create a new FP-tree node whose node_name field is name; |
current- > node_children = node; |
current = = node;//Modify the current pointer to point to the new node |
current- > node_link = item_head; |
item_head = current;//Add it to the item_name linked list whose item_name value is name in the header table |
} |
else increase the node_count value of the child node by 1 and modify the current pointer to point to it; |
} |
|