亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? l maxfpminer.cpp

?? 最大頻繁項集挖掘算法。運行前需將release中的data和result數據拷貝到上一級目錄下。
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
// MiningMaxfp.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define TEMP_INFO_FILE "c:\\tempinfo.txt"
#define PATHLENGTH 100
#define MINNODECOUNT 4000
#define ITEMCOUNT 1000

// Define used types

// Frequency type
typedef unsigned FREQ_TYPE;

// Item type
typedef unsigned ITEM_TYPE;

// Fptree node type
typedef struct FptreeNode{
   	unsigned nNumber;
   	FREQ_TYPE fFrequency;
  	struct FptreeNode *pVertical;
  	struct FptreeNode *pHorizon;
} FPTREENODE;

//  Item information type
typedef struct ItemInfo{
	FREQ_TYPE fFrequency;
    unsigned nNumber;
} ITEMINFO;

// Memory Block type
typedef struct MemoryBlock{
	FPTREENODE *pMBlock;
	struct MemoryBlock *pNext;
} MEMORYBLOCK;

// Declare functions
void Initialize();
void Sift(unsigned nFirst,unsigned nEnd);
void Sort();
void BuildFptree();
void ReverseLink();
void MiningMaxfp();
bool EliminateBranches(FPTREENODE *pV_Root,FPTREENODE *pH_Root);
void PrintMaxpatterns();
void FreeMemory();

// Declare global variables
FREQ_TYPE fSupport;
ITEM_TYPE itMaxItem;
unsigned nTotalLine;
ITEMINFO *arrfItemInfo;
ITEM_TYPE *arritNum;
FPTREENODE *pRoot;
FPTREENODE *pM_Root;
FPTREENODE **arrpFpHorizon;
FPTREENODE *pBlock;
MEMORYBLOCK *pMemory;
FPTREENODE *pNodeRecycle,*pHeaders;
ITEM_TYPE *arrNumberToItem;
FREQ_TYPE *arrfFreq;
unsigned nItemCount,nFPMaxlength;
unsigned nNodeCount,nFptreeNodeCount,nMptreeNodeCount;
unsigned long nMaxfpCount;
unsigned _int64 nTotalMined,nTotal;
FILE *fileData;
FILE *fileResult;
float fDegree;
char *strFileName;
char *strResultFile;
clock_t clockStart;
clock_t clockFirstScan;
clock_t clockBuildFpree;
clock_t clockEnd;

// Main program
int main(int argc,char *argv[])
{
	// Declaration
	FILE *fileInfo;
	float fTemp;
	char ch,p2[PATHLENGTH+1],p3[PATHLENGTH+1];

	if(argc<4)
	{
		// Open tempory mining information file
		if((fileInfo=fopen(TEMP_INFO_FILE,"r"))==NULL)
		{
			puts("Three parameters are needed:");
			puts("Support degree_Result file_Data file.");
			printf("Press ENTER to exit");
			ch=getchar();
			return 0;
		}

		// Read information from temporary information file
		fscanf(fileInfo,"%f%s%s",&fTemp,p2,p3);
		p2[PATHLENGTH]='\0';
		p3[PATHLENGTH]='\0';
		fclose(fileInfo);
		if(argc<4) strFileName=p3;
		if(argc<3) strResultFile=p2;
		if(argc<2) fDegree=fTemp;
	}
	else{
		fDegree=(float)atof(argv[1]);
		strResultFile=argv[2];
		strFileName=argv[3];
	}

	// Write information into temporary file
	if((fileInfo=fopen(TEMP_INFO_FILE,"w"))!=NULL)
	{
		fprintf(fileInfo,"%f\n",fDegree);
		fprintf(fileInfo,"%s\n",strResultFile);
		fprintf(fileInfo,"%s\n",strFileName);

		fclose(fileInfo);
	}

	// Confirm information
	puts("Mining information : ...");
	printf("Data-file path: %s\n",strFileName);
	printf("Supporting degree(%%): %f\n",fDegree);
	printf("The result will be written to file: %s\n\n",strResultFile);
	printf("Press ENTER to confirm and continue");
	ch=getchar();
	if(ch!='\n') return 0;

    // Initialization
	clockStart=clock();
    Initialize();
	clockFirstScan=clock();

	// Print used time in first scaning
	printf("done in seconds %.3f\n",(clockFirstScan-clockStart)/(double)CLOCKS_PER_SEC);

	// Write information to result file
	puts("Data information ...");
	fprintf(fileResult,"Data-file path: %s\n",strFileName);
	fprintf(fileResult,"Maximum item: %u\n",itMaxItem);
	printf("Maximum item: %u\n",itMaxItem);
	fprintf(fileResult,"Total lines: %u\n",nTotalLine);
	printf("Total lines: %u\n",nTotalLine);
	fprintf(fileResult,"Support frequency: %u\n",fSupport);
	printf("Support frequency: %u\n\n",fSupport);
	fprintf(fileResult,"Supporting degree(%%): %f\n",fDegree);

    // Build fptree
    printf("Build fptree ... ");
    BuildFptree();
	clockBuildFpree=clock();
	printf("done in seconds %.3f\n",(clockBuildFpree-clockFirstScan)/(double)CLOCKS_PER_SEC);

    // MiningMaxfp algorithm
    printf("Mining start ... ");
	fprintf(fileResult,"Max-patterns are : ...\n\n");
    MiningMaxfp();
	clockEnd=clock();
	printf("done in seconds %.3f\n",(clockEnd-clockBuildFpree)/(double)CLOCKS_PER_SEC);

    // Print pattern number and used time
	printf("All completed in seconds: %.3f\n\n",(clockEnd-clockStart)/(double)CLOCKS_PER_SEC);
	printf("Total pattern number is: %I64u\n",nTotal-1);
	printf("Total mined pattern number is: %I64u\n",nTotalMined);
	printf("Total max-pattern number is: %lu\n\n",nMaxfpCount);
	fprintf(fileResult,"\nTotal pattern number is: %u\n",nTotal-1);
	fprintf(fileResult,"Total mined pattern number is: %I64u\n",nTotalMined);
	fprintf(fileResult,"Total max-pattern number is: %lu\n",nMaxfpCount);
	fprintf(fileResult,"Count of fptree nodes: %u\n",nFptreeNodeCount);
	fprintf(fileResult,"Count of max-pattern tree nodes: %u\n",nMptreeNodeCount);
	fprintf(fileResult,"Fptree growth completed in seconds: %.3f\n",(clockEnd-clockBuildFpree)/(double)CLOCKS_PER_SEC);
	fprintf(fileResult,"All completed in seconds: %.3f\n",(clockEnd-clockStart)/(double)CLOCKS_PER_SEC);

	// Close result file
	fclose(fileResult);

    // Clear the fptree
	printf("Delete fptree and max-pattern tree ... ");
    FreeMemory();
	puts("done\n");

	printf("Press ENTER to exit");
	ch=getchar();

	return 0;
}

// Initialize the variables
void Initialize()
{
    unsigned i,nLength,nTemp;
	float fTemp;
	ITEM_TYPE item;
	char ch;

	// Open data file
	if((fileData=fopen(strFileName,"r"))==NULL)
	{
		printf("\nCan't open fptree data file. \n");
		printf("Press ENTER to exit");
		ch=getchar();
		exit(1);
	}

	// Allocation
    arrfItemInfo=new ITEMINFO[ITEMCOUNT];

	// Initialize item information
	for(i=0;i<ITEMCOUNT;i++)
	{
		// Initialize information of each item
		arrfItemInfo[i].fFrequency=0;
		arrfItemInfo[i].nNumber=0;
	}

	// Initialization
	nFPMaxlength=0;
	nTotalLine=0;
	itMaxItem=0;
	nLength=ITEMCOUNT;

    // Caculate the frequency of each item while scan the data file
	printf("\nGet data information and sort ... ");
	while(!feof(fileData))
	{
		do
		{
			fscanf(fileData,"%u ",&item);
			if(item==-1)
			{
				nTotalLine++;
				if(!feof(fileData)) continue;
				break;
			}
			if(item>itMaxItem)
			{
				itMaxItem=item;
				if(itMaxItem>=nLength)
				{
					nTemp=nLength;
					while(nLength<=itMaxItem) nLength+=ITEMCOUNT;
					arrfItemInfo=(ITEMINFO *)realloc(arrfItemInfo,nLength*sizeof(ITEMINFO));
					for(i=nTemp;i<nLength;i++)
					{
						// Initialize information of each item
						arrfItemInfo[i].fFrequency=0;
						arrfItemInfo[i].nNumber=0;
					}
				}
			}
			arrfItemInfo[item].fFrequency++;
		}while(1);
	}

	// Extract the array
	realloc(arrfItemInfo,(itMaxItem+1)*sizeof(ITEMINFO));

	// Caculate the support frequency
	fTemp=nTotalLine*fDegree/100;
	fSupport=(FREQ_TYPE)fTemp;
	if(fTemp-fSupport>0.0001) fSupport++;

	// Create result file
	if((fileResult=fopen(strResultFile,"w"))==NULL)
	{
		delete[]arrfItemInfo;
		printf("\nCan't create result file: %s\n",strResultFile);
		printf("Press ENTER to exit");
		ch=getchar();
		exit(2);
	}

	// close data file
	fclose(fileData);

    // Sort the items in term of frequency
    Sort();
}

// Heap-sort algorithm
void Sort()
{
	ITEM_TYPE itTemp,i;
    unsigned j;

    // Create temporary array
    arritNum=new ITEM_TYPE[itMaxItem+2];

	// Initialize the itemfirst-array
    nItemCount=0; 
	for(i=0;i<=itMaxItem;i++)
	{
		if(arrfItemInfo[i].fFrequency<fSupport) continue;
        nItemCount++;
		arritNum[nItemCount]=i;  
	}

	// If no frequent items, exit program
	if(!nItemCount)
	{
		delete[]arritNum;
		delete[]arrfItemInfo;
		printf("no frequent items ... done\n\n");
		printf("Press ENTER to exit");
		getchar();
		exit(0);
	}

	// Create horizontal links
	arrpFpHorizon=new FPTREENODE *[nItemCount+1];

	// Create number to item array
	arrNumberToItem=new ITEM_TYPE[nItemCount+1];

	// Create frequency array
	arrfFreq=new FREQ_TYPE[nItemCount+2];

    // Build heap
    for(j=nItemCount/2;j>0;j--) Sift(j,nItemCount);

	// Sort the elements and store their informations
    for(j=nItemCount;j>0;j--)
    {
        itTemp=arritNum[1];
        arritNum[1]=arritNum[j];
        arrfItemInfo[itTemp].nNumber=j;
        arrNumberToItem[j]=itTemp;
		arrpFpHorizon[j]=0;
		arrfFreq[j]=0;

		Sift(1,j-1);
    }

	// Free allocated memory
    delete[]arritNum;
} 

// Heap adjustment
void Sift(unsigned nFirst,unsigned nEnd)
{
	// Declare variables
    FREQ_TYPE fTemp,fMin,fT;
    ITEM_TYPE itTemp;
    unsigned nCurrent,nNext;

	// Initialization
    itTemp=arritNum[nFirst];
    fTemp=arrfItemInfo[itTemp].fFrequency;
    nCurrent=nFirst;
    nNext=nCurrent+nCurrent;

	// Adjust the heap to a sorted-tree
    while(nNext<=nEnd)
    {
		// Get the smaller son
        fMin=arrfItemInfo[arritNum[nNext]].fFrequency;
        if(nNext<nEnd && fMin>(fT=arrfItemInfo[arritNum[nNext+1]].fFrequency))
        {
            fMin=fT;
            nNext++;
        }

		// Deal with next level
        if(fTemp<=fMin) break;
        else{
            arritNum[nCurrent]=arritNum[nNext];
            nCurrent=nNext;
            nNext=nCurrent+nCurrent;
		}
	}

	// End the adjustment
	arritNum[nCurrent]=itTemp;
}

// Build Fptree
void BuildFptree()
{
	// Declare variables
	unsigned i,j,nCount,nTemp,nN,*arrnTick;
	FPTREENODE *pAnces,*pPre,*pQuery,*pInsert;
	MEMORYBLOCK *pTempMemory;
	ITEM_TYPE item;
	char ch;

	// Initialize fptree node count
	nFptreeNodeCount=1;

	// Ensure an opened data-file
	if((fileData=fopen(strFileName,"r"))==NULL)
	{
		printf("\nCan't open fptree data file. \n");
		printf("Press ENTER to exit");
		ch=getchar();
		exit(3);
	}

	// Create arrnTick array and initialize
	arrnTick=new unsigned[nItemCount+1];
	for(i=0;i<=nItemCount;i++) arrnTick[i]=0;

	// Create first memory block
	pMemory=new MEMORYBLOCK;
	pMemory->pNext=0;
	pBlock=new FPTREENODE[MINNODECOUNT];
	pMemory->pMBlock=pBlock;

	// Initialize fptree root
	pRoot=pBlock;
	pRoot->nNumber=0;
	pRoot->pVertical=0;
	pM_Root=pBlock+1;
	pM_Root->nNumber=nItemCount+1;
	pM_Root->pVertical=pRoot;
	nNodeCount=2;

	// Build the fptree
	while(!feof(fileData))
	{
		// Initialize nCount
		nCount=0;

		// Read another transaction and sort
		do
		{
			// Read another item
			fscanf(fileData,"%u ",&item);
			if(item==-1) break;
		    nTemp=arrfItemInfo[item].nNumber;

			// Ensure an valid item
			if(nTemp!=0)
			{
				// Find the biggest-smaller integer
				i=nCount;
				while(arrnTick[i]>=nTemp) i--;

				// Verify existence
				i++;
				if(arrnTick[i]!=nTemp)
				{
					arrfFreq[nTemp]++;
					nCount++;
					for(j=nCount;j>i;j--) arrnTick[j]=arrnTick[j-1];
					arrnTick[i]=nTemp;
				}
			}

		// If not transaction end , continue
		}while(1);

		// Ensure an unempty transaction
		if(nCount==0) continue;

		// Get maximum-length
		if(nCount>nFPMaxlength) nFPMaxlength=nCount;

		// Initialization
		i=1;
		pAnces=pRoot;

		// Scan the turns of valid items in a transaction
		do
		{
			// Get the head-node
			pPre=pAnces->pVertical;

			// Check descendant NULL
			if(pPre==0)
			{
				do
				{
					// Get the head-node
					nN=arrnTick[i];

					// Create a new fpnode and initialize it
					if(nNodeCount==MINNODECOUNT)
					{
						pTempMemory=pMemory;
						pMemory=new MEMORYBLOCK;
						pMemory->pNext=pTempMemory;
						pBlock=new FPTREENODE[MINNODECOUNT];
						pMemory->pMBlock=pBlock;
						nNodeCount=0;
					}
					pQuery=pBlock+nNodeCount;
					nNodeCount++;
					nFptreeNodeCount++;
  					pQuery->nNumber=nN+nItemCount;
					pQuery->fFrequency=1;
					pQuery->pHorizon=pQuery;

					// Set ancestor-node
					pAnces->pVertical=pQuery;
					pAnces=pQuery;

					// Inspect next item
					arrnTick[i]=0;
					i++;
				}while(i<=nCount);

				// End vertical link
				pAnces->pVertical=0;

				break;
			}

			// Get the current number
			nN=arrnTick[i];

			// Have finded it
			if(pPre->nNumber==nN+nItemCount)
			{
				pPre->fFrequency++;
				pAnces=pPre;

				// Inspect next item
				arrnTick[i]=0;
				i++;

				if(i<=nCount) continue;

				break;
			}

			// Browse in link
			pQuery=pPre->pHorizon;
			while(pQuery->nNumber<nN)
			{
				pPre=pQuery;
				pQuery=pPre->pHorizon;
			}

			// Deal with the result
			if(pQuery->nNumber>nN)
			{
				// Create a new node and initialize it
				if(nNodeCount==MINNODECOUNT)
				{
					pTempMemory=pMemory;
					pMemory=new MEMORYBLOCK;
					pMemory->pNext=pTempMemory;
					pBlock=new FPTREENODE[MINNODECOUNT];
					pMemory->pMBlock=pBlock;
					nNodeCount=0;
				}
				pInsert=pBlock+nNodeCount;
				nNodeCount++;
				nFptreeNodeCount++;
				pInsert->fFrequency=1;
				pInsert->nNumber=nN;

				// Link it to brother link
				pInsert->pHorizon=pQuery;
				pPre->pHorizon=pInsert;

				// Set ancestor node
				pAnces=pInsert;

				// Go to next item
				arrnTick[i]=0;
				i++;

				while(i<=nCount)
				{
					// Get the head-node
					nN=arrnTick[i];

					// Create a new fpnode and initialize it
					if(nNodeCount==MINNODECOUNT)
					{
						pTempMemory=pMemory;
						pMemory=new MEMORYBLOCK;
						pMemory->pNext=pTempMemory;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久综合综合久久综合| 欧美午夜精品电影| 91色.com| 日韩一区二区免费在线观看| 国产免费成人在线视频| 日本不卡在线视频| 91原创在线视频| 国产夜色精品一区二区av| 亚洲www啪成人一区二区麻豆| 成人午夜私人影院| 日韩一卡二卡三卡四卡| 一区二区三区日本| 成人黄色片在线观看| 精品国产sm最大网站| 午夜国产精品影院在线观看| 91碰在线视频| 国产精品久久久久一区二区三区| 久久99精品久久久久久| 欧美三区在线观看| 亚洲免费观看高清完整| 成人性视频免费网站| 久久新电视剧免费观看| 秋霞午夜av一区二区三区| 欧美视频日韩视频在线观看| 亚洲曰韩产成在线| 国产精品18久久久久久久久 | 一区二区免费在线播放| 国产a久久麻豆| 精品不卡在线视频| 精品一区二区免费视频| 制服丝袜亚洲网站| 国产成人午夜精品影院观看视频| 91精品国产高清一区二区三区蜜臀 | 欧美一区欧美二区| 亚洲成人动漫在线免费观看| 欧美在线|欧美| 一区二区三区毛片| 在线一区二区观看| 亚洲高清在线精品| 欧美精品高清视频| 美女诱惑一区二区| 欧美成人艳星乳罩| 国产一区二区不卡老阿姨| 久久久久久亚洲综合影院红桃| 精品一区二区三区视频在线观看| 精品日韩一区二区| 国产成人精品免费在线| 国产精品每日更新在线播放网址 | 日本va欧美va精品发布| 欧美高清视频在线高清观看mv色露露十八 | 国产喷白浆一区二区三区| 国产精品影视在线观看| 国产精品短视频| 在线亚洲高清视频| 日日摸夜夜添夜夜添精品视频| 精品久久久久久久一区二区蜜臀| 久久99精品国产91久久来源| 久久精品一区二区| 色久综合一二码| 日韩国产在线观看| 久久久午夜精品| 99久久伊人精品| 天天色图综合网| 久久久精品人体av艺术| 一本色道亚洲精品aⅴ| 亚洲成人免费看| 久久在线免费观看| 日本乱码高清不卡字幕| 久久精品免费看| 中文字幕一区二区三区蜜月| 欧美高清性hdvideosex| 国产成人aaa| 午夜精品免费在线观看| 久久久久久**毛片大全| 色丁香久综合在线久综合在线观看| 强制捆绑调教一区二区| 国产精品另类一区| 日韩天堂在线观看| 色综合久久久久久久久久久| 九色综合狠狠综合久久| 一区二区三区在线观看欧美| 久久久久久久免费视频了| 欧美午夜精品免费| 成人高清免费在线播放| 水野朝阳av一区二区三区| 国产欧美1区2区3区| 69堂精品视频| 一本大道久久a久久综合婷婷| 精品在线免费观看| 午夜精品123| 亚洲少妇最新在线视频| 国产清纯在线一区二区www| 777午夜精品视频在线播放| 不卡在线观看av| 极品美女销魂一区二区三区免费| 亚洲国产成人精品视频| 中文字幕在线视频一区| 国产亚洲制服色| 日韩精品资源二区在线| 欧美中文字幕不卡| 99re这里只有精品视频首页| 国产精品资源网站| 九色综合狠狠综合久久| 日本特黄久久久高潮| 亚洲一区自拍偷拍| 一区二区三区在线播| 日韩一区在线免费观看| 中文字幕av一区二区三区高| 亚洲精品一区二区三区影院| 欧美一级精品在线| 欧美肥胖老妇做爰| 在线播放/欧美激情| 欧美在线观看你懂的| 在线视频综合导航| 欧美中文字幕一区二区三区亚洲| 在线亚洲精品福利网址导航| 在线亚洲一区二区| 91国产免费观看| 欧美亚洲免费在线一区| 欧美群妇大交群中文字幕| 在线看日本不卡| 欧美日韩免费观看一区三区| 欧美性大战久久久久久久| 欧美少妇性性性| 宅男在线国产精品| 精品久久久三级丝袜| 久久综合中文字幕| 欧美激情一区二区三区在线| 国产精品久久久久久久久动漫 | 欧美精品一区二区在线播放 | 国产日韩欧美不卡| 欧美激情一区二区三区全黄 | 亚洲mv在线观看| 免费看日韩a级影片| 久久99精品国产.久久久久| 国产在线视视频有精品| 成人三级伦理片| 色哟哟一区二区| 911国产精品| 国产区在线观看成人精品| 亚洲免费伊人电影| 日韩国产在线一| 国产高清精品网站| 色偷偷一区二区三区| 欧美久久免费观看| 久久久综合视频| 激情偷乱视频一区二区三区| 国产成人精品免费一区二区| 97久久超碰国产精品| 555www色欧美视频| 国产欧美1区2区3区| 婷婷一区二区三区| 国产成人免费视频一区| 91国偷自产一区二区使用方法| 日韩欧美国产一区在线观看| 国产精品乱码人人做人人爱 | 精品视频全国免费看| 精品99999| 一区二区三区电影在线播| 久久精品国产秦先生| 91亚洲精品一区二区乱码| 日韩欧美高清dvd碟片| 中文字幕一区二区三区色视频| 丝袜a∨在线一区二区三区不卡| 国产91在线|亚洲| 欧美福利视频一区| 国产精品无圣光一区二区| 日韩经典中文字幕一区| 91小视频免费观看| 久久亚洲一区二区三区四区| 亚洲国产一区二区a毛片| 国产电影一区在线| 欧美精品精品一区| 亚洲免费观看视频| 成人激情免费电影网址| 日韩一区二区精品| 亚洲成人综合视频| 色综合久久综合网| 国产精品乱人伦| 国产精品77777竹菊影视小说| 欧美日韩电影在线| 一区二区欧美国产| 91在线国内视频| 国产精品入口麻豆九色| 久久99精品国产.久久久久| 欧美日本在线一区| 亚洲午夜国产一区99re久久| 成人a免费在线看| 国产欧美日韩视频在线观看| 久久国产三级精品| 制服丝袜一区二区三区| 亚洲成人动漫在线观看| 色av成人天堂桃色av| 亚洲天堂网中文字| 欧美成人官网二区| 日韩av中文字幕一区二区| 欧美午夜精品一区二区三区| 亚洲综合久久久久| 欧美色网站导航| 午夜婷婷国产麻豆精品|