?? fpgrowth.java
字號:
package association.fptree;
import java.io.*;
import java.util.LinkedList;
import association.fptree.ITree.Node;
/**
* FP_growth算法
* @author qjt
*
*/
public class FPGrowth {
int minSupport=1;
CreateFPTree ct;
ITree iTree; //存儲挖掘出的所有項集的樹
FPGrowth(){
ct=new CreateFPTree();
}
/*主程序*/
public void Start(FPTree tree,ITree itr,int supp){
iTree=itr;
minSupport=supp;
FP_growth(tree,itr.head);
}
/**
* fp-growth算法
* @param tree FPtree
* @param head 頻繁項集樹的頭結點
* */
public void FP_growth(FPTree tree,LinkedList<Node> head){
FPTree branch; //條件FPTree
String itemName;
int len,i=0,count;
LinkedList<Node> l,cl;
ITree itr=new ITree();
ITree.Node node;
l=head;
len=tree.itemTb.Length();
while(i<len){
count=tree.itemTb.ReadCount(i);
if (count<minSupport){
i++;
continue;
}
itemName=tree.itemTb.ReadItem(i);
node=itr.new Node(itemName,count);
l.add(node);
branch=ct.ConditionFPT(tree,itemName); //產生條件FP樹
if (branch==null){ /*如果沒有產生條件FPTree,
當一個項只是root結點下的子結點是就不會產生條件FPTree */
i++;
continue;
}
cl=new LinkedList<Node>();
node.cNode=cl;
FP_growth(branch,cl);
branch=null;
i++;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -