⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apriori.h

📁 apriori经典算法及一个改进算法的程序,里面有具体的解析与操作
💻 H
字号:
//***********************************************//
// 程序编写者:wentrue
// 编译环境:VC7.0,控制台程序
// 关于本程序的任何问题或意见,可联系本人:wentrue@mail.ustc.edu.cn
//***********************************************//
#pragma once

#include "resource.h"

typedef struct tagDBLink{     //数据库元组数据链表
	CString datastr;          //关键字记录串元组
	struct tagDBLink *next;   //下一串指针
}DBLink;

typedef struct tagSearchTree{    //1-项集搜索树
	CString datastr;             //节点存储的关键字
	WORD count;                  //该关键字出现次数
	struct tagSearchTree *left;  //左子树指针
	struct tagSearchTree *right; //右子树指针
}SearchTree;

typedef struct tagItemSet{    //K-项集链表
	CString datastr;          //节点存储的关键字
	WORD count;               //该关键字出现的次数
	struct tagItemSet *next;  //下一节点的指针
}ItemSet,ItemSetLink,ItemSetNode;

SearchTree* find_frequent_1_itemset(DBLink* D,int min_count);   //从数据库元组数据链表中,发现频繁1-项集 
ItemSet* find_frequent_k_itemset(DBLink* D,ItemSet* IS,int k,int min_count);    //扫描数据集发现k-项集
ItemSetLink* apriori_gen(ItemSet* IS,int k);    //根据频繁k-1项集链表IS产生候选k-项集链表
BOOL has_infrequent_subset(CString str,ItemSet* IS);    //搜索候选k-项集中k-1项集不频繁的元素
BOOL FindInTree(SearchTree* ST,CString str);    //在二叉搜索树中搜索指定关键字
ItemSetNode* GetDataLink(SearchTree* ST);     //把二叉搜索树中的结点按升序读取出来组成链表
SearchTree* SearchAndAddInTree(SearchTree* ST,CString str,int k);    //在给定的搜索二叉树中搜索指定的字符串(中序),并增加计数
ItemSet* SearchAndAddIn_kLink(ItemSetLink* IS,CString str);   //生成k-项频繁集候选集的搜索二叉树
SearchTree* SearchAndDelInTree(SearchTree* ST,int min_count);    //在给定的搜索二叉树中剔除掉出现次数低于min_count的结点
SearchTree* FindMin(SearchTree* ST);      //在ST中搜索最小的元素
SearchTree* DeleteNode(SearchTree* ST,CString str);     //在ST中搜索关键字为str的节点并删除
CString GetLine(CFile* const f);    //从文件中读出一行字符
DBLink* ReadDataFromText(CString filename,int *RC);     //从TXT文件中读入数据
void PrintResult(ItemSet* IS,int k,CString exstr1);     //输出频繁集结果
//BOOL CompareKeyInStr(CString str1,CString str2);    //在str1的关键字组中寻找str2的关键字是否都出现
ItemSetLink* CreatePreItemSet(ItemSetLink* preIS,CString str,int k);     //构建候选频繁k项集链表
ItemSetLink* DeleteLink(ItemSetLink* IS);    //释放链表IS的内存空间
ItemSet* Del_k_ItemSet(ItemSet* IS,int min_count);     //在已计数好的ItemSet中删除非频繁节点
SearchTree* DeleteTree(SearchTree* ST);    //释放二叉树节点

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -