// FP.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <string>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <list>
using namespace std;
const int kMinSupport = 2;
map<list<string>, int> FreqPattern;
struct TreeNode {
int count;
string tag;
map<string, TreeNode*> children;
TreeNode* parent;
TreeNode* Sibling;
TreeNode(string tag, TreeNode* parent, int count = 1) : tag(tag), parent(parent), count(count) {
Sibling = NULL;
children.clear();
}
bool IsRoot() {
return (parent == NULL);
}
void dump(int k) {
for(int i = 0; i < k; i++) {
printf("--------");
}
if (IsRoot()) {
printf("\nRoot \n");
} else {
printf("%s:%d \n", tag.c_str(), count);
}
map<string, TreeNode*>::iterator it;
for(it = children.begin(); it != children.end(); it++) {
printf("|");
it->second->dump(k+1);
}
}
};
void GenConditionalTree(map<vector<string>, int>& Task,
map<string, TreeNode*>& head,
TreeNode& root,
map<string, int>& FreqTable,
vector<string>& rank,
bool prune);
map<string, int>* gFreqTable = NULL;
bool Compare(string a, string b) {
int aw = (*gFreqTable)[a];
int bw = (*gFreqTable)[b];
return (aw > bw);
}
void GenPermutation(vector<string>& prefix_set, int start, list<string>& result, int freq, int suffix_len) {
// last one;
if (sta
FP tree 算法 C++ 实现
最新推荐文章于 2019-05-15 19:32:22 发布
本文详细介绍了如何使用C++实现FP树算法,通过示例展示了如何处理交易数据,生成条件模式基,并通过递归生成频繁模式。文章涵盖了FP树的构建、条件树生成及其在单路和多路径情况下的应用。
摘要由CSDN通过智能技术生成