📄 myapriori.h
字号:
//***********************************************//
// 程序编写者:wentrue
// 编译环境:VC7.0,控制台程序
// 关于本程序的任何问题或意见,可联系本人:wentrue@mail.ustc.edu.cn
//***********************************************//
#pragma once
#include "resource.h"
typedef struct tagKeyTree{ //数据库关键字树
CString Key; //关键字
CString IndexSet; //关键字出现的记录号的集,以分号分隔
WORD count; //关键字在数据库中出现的次数
struct tagKeyTree *left; //指向左儿子的指针
struct tagKeyTree *right; //指向右儿子的指针
}KeyTree;
typedef struct tagItemSet{ //K-项集链表
CString datastr;
WORD count;
struct tagItemSet *next;
}ItemSet,ItemSetLink;
KeyTree* ReadDataFromText(CString filename,int *RC); //从TXT文件中读入数据
CString GetLine(CFile* const f); //从文件中读出一行字符
KeyTree* UpdateKeyTree(KeyTree* KT,CString sw,int count); //根据读入的每一组关键字,更新关键字树
ItemSet* find_frequent_1_itemset(KeyTree* KT,int min_count); //发现1-项集
KeyTree* FindMin(KeyTree* KT); //在KT中搜索最小的元素
KeyTree* DeleteNode(KeyTree* ST,CString str); //在KT中搜索关键字为str的节点并删除
KeyTree* SearchAndDelInTree(KeyTree* KT,int min_count); //在给定的搜索二叉树中剔除掉出现次数低于min_count的结点
ItemSetLink* GetDataLink(KeyTree* KT); //把二叉搜索树中的结点按升序读取出来组成链表
void PrintResult(ItemSet* IS,int k,CString exstr1); //输出频繁集结果
ItemSetLink* apriori_gen(ItemSet* IS,int k); //根据频繁k-1项集IS产生候选k-项集
ItemSet* find_frequent_k_itemset(KeyTree* KT,ItemSetLink* preIS,int k,int min_count); //扫描关键字树发现k-项集
BOOL has_infrequent_subset(CString str,ItemSet* IS); //搜索候选k-项集中k-1项集不频繁的元素
ItemSetLink* CreatePreItemSet(ItemSetLink* preIS,CString str,int k); //构建候选频繁k项集链表
CString FindInKeyTree(KeyTree* KT,CString str); //在关键字树中搜索str,并返回相应的IndexSet字段
int CountForKey(CStringArray* SA,int k); //根据存储在SA中的几个IndexSet字符串,计算其公共子串的数目
int MinnIndex(int* nIndexArray,int k); //返回数组中最大值的下标
BOOL SomeIsEnd(int* nStart,int k); //检测某些字符串是否已经检索结束
void GetRecordNum(CStringArray* SA,int* nValue,int* nStart,int* nEnd,int k); //从SL中获得下一组记录号
ItemSet* Del_k_ItemSet(ItemSet* IS,int min_count); //在已计数好的ItemSet中删除非频繁节点
ItemSetLink* DeleteLink(ItemSetLink* IS); //释放链表IS的内存空间
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -