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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? hierarchy.c

?? 數(shù)據(jù)挖掘算法BIRCH源碼 c語(yǔ)言版本。
?? C
字號(hào):
/****************************************************************File Name: hierarchy.C  Author: Tian Zhang, CS Dept., Univ. of Wisconsin-Madison, 1995               Copyright(c) 1995 by Tian Zhang                   All Rights ReservedPermission to use, copy and modify this software must be grantedby the author and provided that the above copyright notice appear in all relevant copies and that both that copyright notice and this permission notice appear in all relevant supporting documentations. Comments and additions may be sent the author at zhang@cs.wisc.edu.******************************************************************/#include <assert.h>#include "global.h"#include "util.h"#include "vector.h"#include "rectangle.h"#include "cfentry.h"#include "cutil.h"#include "parameter.h"#include "hierarchy.h"/* for MergeHierarchy use only */static void Update_Distance(int n1, int n2, int CurI, int NextI, 			    int n, int *checked, double *dist){int 	i, j;double  d1, d2;for (i=0; i<CurI; i++) {      if (checked[i]!=0) {	if (i!=NextI) {      		d1 = dist[i*n-i*(i+1)/2+CurI-i-1];      		if (i<NextI) d2 = dist[i*n-i*(i+1)/2+NextI-i-1];      		else d2 = dist[NextI*n-NextI*(NextI+1)/2+i-NextI-1];      		dist[i*n-i*(i+1)/2+CurI-i-1] = (n1*d1+n2*d2)/(n1+n2);      	}}}for (j=CurI+1; j<n; j++) {      if (checked[j]!=0) {	if (j!=NextI) {		d1 = dist[CurI*n-CurI*(CurI+1)/2+j-CurI-1];		if (j<NextI) d2 = dist[j*n-j*(j+1)/2+NextI-j-1];		else d2 = dist[NextI*n-NextI*(NextI+1)/2+j-NextI-1];		dist[CurI*n-CurI*(CurI+1)/2+j-CurI-1] = (n1*d1+n2*d2)/(n1+n2);      	}}}}/* for MergeHierarchy use only */static int Pick_One_Unchecked(int n, int *checked){int i,j = rand() % n;for (i=0;i<n;i++) 	if (checked[(i+j)%n]!=0) return (i+j)%n;return -1;}/* for MergeHierarchy use only */static int Nearest_Neighbor(int CurI, int n, int *checked, double *dist){int    i, imin=0;double d, dmin = HUGE;for (i=0;i<CurI;i++) {    if (checked[i]!=0){	d = dist[i*n-i*(i+1)/2+CurI-i-1];	if (d<dmin) { dmin=d; imin=i; }	}}for (i=CurI+1;i<n;i++) {    if (checked[i]!=0){	d = dist[CurI*n-CurI*(CurI+1)/2+i-CurI-1];	if (d<dmin) { dmin=d; imin=i; }	}}if (dmin<HUGE) return imin;else return -1;}/* for SplitHierarchy use only */static int Farthest_Merge(int chainptr, int *chain, double *dd) {if (chainptr<=0) return chainptr;double d, dmax = 0;int    i, imax = -1;for (i=0; i<=chainptr; i++) {	if (chain[i]<0) {		d = dd[-chain[i]-1];		if (d>dmax) {imax = i; dmax = d;}		}}return imax;}/* for SplitHierarchy use only */static int Largest_Merge(int chainptr, int *chain, Entry *cf, short ftype, double ft){for (int i=0; i<=chainptr; i++) {	if (chain[i]<0) {		if (cf[-chain[i]-1].Fitness(ftype)>ft)			return i;			}}return -1;}/*********************************************************************This is an O(n^2) algorithm, but works only for D2 and D4 due to the "REDUCIBILITY PROPERTY" that is given as below:if d(i,j) < p, d(i,k) > p, d(j,k) > p then d(i+j,k) > p.Algorithm:Part 1: MergeHierarchy:	form the complete hierarchy in O(n^2) time	step1: Pick any cluster i[1].	step2: Determine the chain i[2]=NN(i[1]), i[3]=NN(i[2]) ... 	       until i[k]=NN(i[k-1]) and i[k-1]=NN(i[k]), where NN 	       means nearest neighbor.	step3: Merge clusters i[k-1] and i[k].	step4: If more than 1 clusters left, goto step using i[k-2] 	       as start if (k-2>0), otherwise choose arbitrary i[1].Part 2: SplitHierarchy:	cut from the complete hierarchy in O(n^2) 		by number of clusters K, 		by the threshold Ft, 		by tree height H,		...*********************************************************************/void Hierarchy::MergeHierarchy(short gdtype,    // distance type			       int nentry,      // number of entries                               Entry *entries)  // array storing entries{if (gdtype!=D2 && gdtype!=D4) 	print_error("MergeHierarchy","only support distance D2 and D4");int 	i,j,n1,n2;int	CurI, PrevI, NextI;int 	uncheckcnt = nentry;int 	*checked = new int[nentry];for (i=0;i<nentry;i++) checked[i]=i+1;	// 0: invalid after being merged to other entries	// positive 1..nentry+1 :     original entries	// negative -1..-(nentry-1) : merged entries// get initial distancesdouble *dist=new double[nentry*(nentry-1)/2];for (i=0; i<nentry-1; i++)  for (j=i+1; j<nentry; j++) 	dist[i*nentry-i*(i+1)/2+j-i-1] = 		distance(gdtype,entries[i],entries[j]);	CurI = rand() % nentry;			// step1 chain[++chainptr]=CurI;while (uncheckcnt>1) {   if (chainptr==-1) {			// step4	chainptr++;  	chain[chainptr]=Pick_One_Unchecked(nentry,checked); 	}   if (chainptr>0) 	PrevI=chain[chainptr-1];   else PrevI=-1;   stopchain=FALSE;   while (stopchain==FALSE) {		// step2		CurI=chain[chainptr];	NextI = Nearest_Neighbor(CurI,nentry,checked,dist);	// it is impossible NextI be -1 because uncheckcnt>1	if (NextI==PrevI)	  stopchain = TRUE;	else {	  chain[++chainptr]=NextI;	  PrevI = CurI;	  }	} // end of while for step 2   step++;   ii[step] = checked[CurI];			// step3   jj[step] = checked[NextI];   if (CurI<NextI) 	dd[step] = dist[CurI*nentry-CurI*(CurI+1)/2+NextI-CurI-1];   else 	dd[step] = dist[NextI*nentry-NextI*(NextI+1)/2+CurI-NextI-1];   if (checked[CurI]>0) {	n1 = entries[CurI].n;	if (checked[NextI]>0) {		n2 = entries[NextI].n;   		cf[step].Add(entries[CurI],entries[NextI]);		}	else  {		n2 = cf[-checked[NextI]-1].n;		cf[step].Add(entries[CurI],cf[-checked[NextI]-1]);		}	}   else {	n1 = cf[-checked[CurI]-1].n;	if (checked[NextI]>0) {		n2 = entries[NextI].n;		cf[step].Add(cf[-checked[CurI]-1],entries[NextI]);		}	else {		n2 = cf[-checked[NextI]-1].n;		cf[step].Add(cf[-checked[CurI]-1],cf[-checked[NextI]-1]);		}	}   Update_Distance(n1,n2,CurI,NextI,nentry,checked,dist);   uncheckcnt--;   checked[CurI] = -(step+1);	       checked[NextI] = 0;   chainptr--; chainptr--;   } //end of while (uncheckcnt>1)if (checked) delete [] checked;if (dist) delete [] dist;// prepare for SplitHierarchystopchain = FALSE;chainptr = 0;chain[chainptr] = -(step+1);}short Hierarchy::SplitHierarchy(short option,short ftype,double ft){int i, j;switch (option) {case BY_THRESHOLD:	if (stopchain==TRUE) return FALSE;	i = Largest_Merge(chainptr,chain,cf,ftype,ft);	if (i!=-1) {j = -chain[i]-1;		    chain[i] = ii[j];		    chain[++chainptr]=jj[j];		    return TRUE;		    }	else {stopchain = TRUE; return FALSE;}	break;	case BY_KCLUSTERS:	if (chainptr==size) return FALSE;	i = Farthest_Merge(chainptr,chain,dd);	if (i!=-1) {j = -chain[i]-1;		    chain[i]=ii[j];		    chain[++chainptr]=jj[j];		    return TRUE;		    }        else return FALSE;	break;	}}double Hierarchy::MinFtMerged(short ftype){int MinI;double tmpFt, MinFt=HUGE_DOUBLE;for (int i=0; i<=chainptr; i++) {	if (chain[i]<0) {		tmpFt=cf[-chain[i]-1].Fitness(ftype);		if (tmpFt<MinFt) {MinFt=tmpFt; MinI=i;}		}	}// prepare for physically merging the MinI clusterstopchain=FALSE;chainptr=0;chain[0]=chain[MinI];return MinFt;}double Hierarchy::DistortionEdge(Entry *entries){double TotalDistort=0;for (int i=0; i<=chainptr; i++) {	if (chain[i]<0)		TotalDistort+=cf[-chain[i]-1].N()*cf[-chain[i]-1].Radius();	else TotalDistort+=entries[chain[i]-1].N()*entries[chain[i]-1].Radius();	}return TotalDistort;}double Hierarchy::NmaxFtMerged(short ftype){double NmaxFt;int    maxn;maxn = 0; NmaxFt=0;for (int i=0; i<=chainptr; i++) {	if (chain[i]<0 && cf[-chain[i]-1].N()>maxn) {		maxn = cf[-chain[i]-1].N();		NmaxFt = cf[-chain[i]-1].Fitness(ftype);		}	}return NmaxFt;}double Hierarchy::TotalFtDEdge(short ftype, short d, Entry *entries){double TotalFtD=0;for (int i=0; i<=chainptr; i++) {	if (chain[i]<0) 		TotalFtD+=pow(cf[-chain[i]-1].Fitness(ftype),1.0*d);	else TotalFtD+=pow(entries[chain[i]-1].Fitness(ftype),1.0*d);	}return TotalFtD;}/***********************************************************This is an O(n^3) algorithm, but works fine for all 5(D0,D1,D2,D3,D4) distance definitions.  It is used to make sure Hierarchy1 and Hierarchy0 can produce the same results for debugging purpose.************************************************************/void Hierarchy0(int &n, 	 // final number of clusters		const int K,     // final number of clusters		Entry **entries,		short GDtype,		short Ftype,		double Ft){if (n<=1) return;int 	i, j, imin, jmin, done;short  	*checked = new short[n];memset(checked,0,n*sizeof(short));	// 0: unchecked;	// -1: exceeds the given threshold if merged with nearest neighbor;	// -2: nonexistant after merging.double 	*dist = new double[n*(n-1)/2];double 	d, dmin;Entry 	tmpent;tmpent.Init((*entries)[0].sx.dim);dmin = HUGE;	// compute all initial distances and closest pairfor (i=0; i<n-1; i++)  for (j=i+1; j<n; j++) {	d = distance(GDtype,(*entries)[i],(*entries)[j]);	dist[i*n-i*(i+1)/2+j-i-1] = d;	if (d<dmin) {		dmin = d;		imin = i;		jmin = j;		}	}if (K==0) {// ****** case 1 ****** cluster by threshold ftdone = FALSE;while (done==FALSE) {	tmpent.Add((*entries)[imin],(*entries)[jmin]);	if (tmpent.Fitness(Ftype) < Ft) { 	// within the threshold		(*entries)[imin] += (*entries)[jmin];		checked[jmin] = -2;		for (i=0; i<imin; i++) {		   if (checked[i]==0) {		   dist[i*n-i*(i+1)/2+imin-i-1] = 			distance(GDtype,(*entries)[i],(*entries)[imin]);		   }}		for (j=imin+1; j<n; j++) {		   if (checked[j]==0) {		   dist[imin*n-imin*(imin+1)/2+j-imin-1] =			distance(GDtype,(*entries)[imin],(*entries)[j]);		   }}		}	else { 	// exceeds the threshold		checked[imin] = -1;		checked[jmin] = -1;		}	done = TRUE;	dmin = HUGE;	for (i=0; i<n-1; i++) {	  if (checked[i]==0) {	  for (j=i+1; j<n; j++) {		if (checked[j]==0) {			d = dist[i*n-i*(i+1)/2+j-i-1];			if (d<dmin) {				done = FALSE;				dmin = d;				imin = i;				jmin = j;	}}}}} 	} // end of while} // end of ifelse { // ***** case 2 ***** cluster by number k	done = n;while (done > K) {	(*entries)[imin] += (*entries)[jmin];	checked[jmin] = -2;	done--;	for (i=0; i<imin; i++) {	   if (checked[i]==0) {	   dist[i*n-i*(i+1)/2+imin-i-1] = 		distance(GDtype,(*entries)[i],(*entries)[imin]);	   }}	for (j=imin+1; j<n; j++) {	   if (checked[j]==0) {	   dist[imin*n-imin*(imin+1)/2+j-imin-1] =		distance(GDtype,(*entries)[imin],(*entries)[j]);	   }}	dmin = HUGE;	for (i=0; i<n-1; i++) {	  if (checked[i]==0) {	  for (j=i+1; j<n; j++) {		if (checked[j]==0) {		d = dist[i*n-i*(i+1)/2+j-i-1];			if (d<dmin) {			dmin = d;			imin = i;			jmin = j;	}}}}}	} // end of while} // end of elsej = 0;for (i=0; i<n; i++)   if (checked[i]!=-2) {	(*entries)[j]=(*entries)[i];	j++;	}n=j;delete [] checked;delete [] dist;}/*********************************************************************This is an O(n^2) algorithm, but works only for D2 and D4 due to the "REDUCIBILITY PROPERTY" that is given as below:if d(i,j) < p, d(i,k) > p, d(j,k) > p then d(i+j,k) > p.Algorithm:Part 1: Form the complete hierarchy in O(n^2) time	step1: Pick any cluster i[1].	step2: Determine the chain i[2]=NN(i[1]), i[3]=NN(i[2]) ... 	       until i[k]=NN(i[k-1]) and i[k-1]=NN(i[k]), where NN 	       means nearest neighbor.	step3: Merge clusters i[k-1] and i[k].	step4: If more than 1 clusters left, goto step using i[k-2] 	       as start if (k-2>0), otherwise choose arbitrary i[1].Part 2: Split from the complete hierarchy in O(n^2) 		by number of clusters K, 		by the threshold Ft, 		by tree height H,		...*********************************************************************/void Hierarchy1(int &n, 	// final number of clusters		const int K,    // final number of clusters		Entry **entries,// array storing clusters		short GDtype,		short Ftype,		double Ft){if (GDtype!=D2 && GDtype!=D4) 	print_error("Hierarchy1","only support distance D2 and D4");if (n<=1) return;if (n==K) return;// ****************** Part 1 **********************Hierarchy *h = new Hierarchy(n-1,(*entries)[0].sx.dim);h->MergeHierarchy(GDtype,n,*entries);// ******************* Part 2 *********************if (K==0) { 	// by the threshold	while (h->SplitHierarchy(BY_THRESHOLD,Ftype,Ft)==TRUE);	}else 	{		// by the number of clusters	while (h->chainptr+1<K && 	       h->SplitHierarchy(BY_KCLUSTERS,Ftype,Ft)==TRUE);	}// ******************* Part 3 *********************int j;Entry *tmpentries = new Entry[h->chainptr+1];for (j=0;j<=h->chainptr;j++) 	tmpentries[j].Init((*entries)[0].sx.dim);for (j=0;j<=h->chainptr;j++) {	if (h->chain[j]<0) 		tmpentries[j] = h->cf[-h->chain[j]-1];	else 	tmpentries[j] = (*entries)[h->chain[j]-1];	}delete [] *entries;*entries = tmpentries;n=h->chainptr+1;delete h;}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美美女一区二区在线观看| 精品国产一区二区三区久久影院| 视频一区二区三区在线| 久久久久免费观看| 欧美午夜理伦三级在线观看| 国产成人免费视频网站高清观看视频| 亚洲国产日韩a在线播放| 久久久www成人免费毛片麻豆 | av成人免费在线| 美女爽到高潮91| 一区二区三区精品| 亚洲国产精品99久久久久久久久| 日韩视频国产视频| 欧美中文一区二区三区| 成人高清伦理免费影院在线观看| 精品一区二区在线视频| 五月婷婷综合在线| 一区二区三区在线观看欧美| 中文字幕免费不卡在线| 337p粉嫩大胆噜噜噜噜噜91av| 在线成人av网站| 91免费观看在线| 成人的网站免费观看| 国产成人免费视频网站高清观看视频| 美女视频一区二区| 男人操女人的视频在线观看欧美| 一区二区国产盗摄色噜噜| 亚洲视频中文字幕| 中文字幕的久久| 日本一区二区在线不卡| 久久先锋影音av| 亚洲精品一区在线观看| 日韩欧美中文一区二区| 91精品黄色片免费大全| 欧美夫妻性生活| 91精品国产麻豆国产自产在线| 欧美日韩午夜在线视频| 欧美日韩精品一区二区天天拍小说 | 亚洲第一会所有码转帖| 亚洲精品国产成人久久av盗摄| 国产精品乱码一区二三区小蝌蚪| 久久精品人人做人人爽人人| 久久亚洲二区三区| 久久综合国产精品| 精品播放一区二区| 久久久美女艺术照精彩视频福利播放| 久久中文字幕电影| 国产亚洲一本大道中文在线| 国产女同互慰高潮91漫画| 国产欧美日韩另类一区| 国产精品第一页第二页第三页| 国产精品美女久久久久久久| 亚洲欧美一区二区视频| 亚洲精品国产一区二区精华液| 亚洲精品免费视频| 亚洲高清不卡在线| 乱中年女人伦av一区二区| 精彩视频一区二区三区| 国产精品888| 91免费看`日韩一区二区| 欧美最新大片在线看| 91精品国产日韩91久久久久久| 精品噜噜噜噜久久久久久久久试看 | 在线观看成人小视频| 欧美人与z0zoxxxx视频| 日韩免费福利电影在线观看| 久久九九久久九九| 日韩伦理免费电影| 日韩精品一级中文字幕精品视频免费观看 | 亚洲高清三级视频| 黄网站免费久久| 成人免费视频一区| 欧美视频中文一区二区三区在线观看| 欧美精品777| 国产欧美日韩在线观看| 亚洲午夜影视影院在线观看| 久久精品国产精品亚洲综合| 成人久久18免费网站麻豆| 欧美综合视频在线观看| 精品免费日韩av| 亚洲伦理在线免费看| 美女精品一区二区| 99久久er热在这里只有精品15| 欧美三级日韩三级| 久久久久久一二三区| 亚洲女同一区二区| 精久久久久久久久久久| 欧美性视频一区二区三区| 精品国产一二三| 亚洲午夜免费福利视频| 国产久卡久卡久卡久卡视频精品| 色婷婷av一区二区三区之一色屋| 日韩欧美的一区二区| 亚洲素人一区二区| 麻豆国产一区二区| 91成人网在线| 国产欧美日韩麻豆91| 日韩中文字幕不卡| 99久久精品国产麻豆演员表| 日韩美女在线视频| 亚洲二区视频在线| youjizz国产精品| 精品国产网站在线观看| 亚洲综合图片区| 成人综合在线网站| 日韩免费高清电影| 亚洲超碰精品一区二区| 成人国产精品免费| 久久综合九色综合欧美亚洲| 日韩中文字幕麻豆| 在线视频国内自拍亚洲视频| 亚洲国产成人在线| 激情小说欧美图片| 欧美一区二区三区免费在线看 | 从欧美一区二区三区| 日韩免费高清电影| 天堂午夜影视日韩欧美一区二区| 色综合久久久久综合99| 国产精品久久免费看| 国产乱国产乱300精品| 精品久久人人做人人爰| 日本免费在线视频不卡一不卡二| 欧美日韩免费观看一区三区| 亚洲人成在线播放网站岛国| 不卡一区二区在线| 欧美国产成人精品| 国产mv日韩mv欧美| 国产亚洲自拍一区| 国产成人丝袜美腿| 国产欧美日韩综合| 国产成人啪午夜精品网站男同| 久久这里只有精品首页| 国产一区91精品张津瑜| 2023国产精品| 国产精品一区二区x88av| 亚洲精品在线免费观看视频| 韩日欧美一区二区三区| 欧美精品一区二区三区蜜桃 | 性做久久久久久久免费看| 日本精品裸体写真集在线观看| 亚洲卡通欧美制服中文| 色综合久久久久| 亚洲国产aⅴ天堂久久| 欧美欧美欧美欧美首页| 日韩av午夜在线观看| 日韩免费一区二区三区在线播放| 美女免费视频一区二区| 久久亚区不卡日本| av动漫一区二区| 亚洲一区二区三区四区不卡| 欧美高清dvd| 国产在线麻豆精品观看| 国产精品久久午夜夜伦鲁鲁| 色综合中文字幕国产| 亚洲美女一区二区三区| 欧美日韩激情在线| 九九九久久久精品| 中文字幕欧美国产| 欧美亚洲一区二区三区四区| 午夜精品久久一牛影视| 欧美精品一区视频| 成人激情小说乱人伦| 亚洲精品国产精华液| 91精品国产色综合久久ai换脸| 国产精品996| 一区二区在线免费| 精品国产一区久久| 91免费观看视频在线| 视频一区视频二区中文| 国产拍揄自揄精品视频麻豆| 91国偷自产一区二区开放时间| 日本午夜精品视频在线观看| 一区二区三区欧美日韩| 欧美一区二区成人| 丁香婷婷综合五月| 亚洲成人精品影院| 亚洲国产精品高清| 欧美日本不卡视频| 粉嫩欧美一区二区三区高清影视| 亚洲激情av在线| 久久天天做天天爱综合色| 日本丰满少妇一区二区三区| 久久99在线观看| 日韩一区在线播放| 日韩三级高清在线| 色偷偷88欧美精品久久久| 男女男精品视频| 亚洲欧美日韩综合aⅴ视频| 欧美岛国在线观看| 色噜噜狠狠色综合中国 | 在线精品视频免费播放| 精品一区二区三区视频| 夜夜亚洲天天久久| 欧美经典一区二区| 日韩一区二区三区电影在线观看 | 久久色视频免费观看| 在线看不卡av| av中文字幕亚洲| 国产精品1区二区.| 蜜桃视频免费观看一区|