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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? maxheap.h

?? 大型復(fù)雜網(wǎng)絡(luò)社區(qū)劃分的快速算法
?? H
字號:
////////////////////////////////////////////////////////////////////////// --- COPYRIGHT NOTICE ---------------------------------------------// FastCommunityMH - infers community structure of networks// Copyright (C) 2004 Aaron Clauset//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA// // See http://www.gnu.org/licenses/gpl.txt for more details.// ////////////////////////////////////////////////////////////////////////// Author       : Aaron Clauset  (aaron@cs.unm.edu)				//// Location     : U. Michigan, U. New Mexico						//// Time         : January-August 2004							//// Collaborators: Dr. Cris Moore (moore@cs.unm.edu)				////              : Dr. Mark Newman (mejn@umich.edu)				//////////////////////////////////////////////////////////////////////////#if !defined(TUPLE_INCLUDED)#define TUPLE_INCLUDEDstruct tuple {	double    m;					// stored value	int		i;					// row index	int		j;					// column index	int		k;					// heap index};#endif#if !defined(MAXHEAP_INCLUDED)#define MAXHEAP_INCLUDED#include <iostream.h>/*   Because using this heap requires us to be able to modify an arbitrary element's	data in constant O(1) time, I use to tricky tactic of having elements in an array-	based heap only contain addresses to the data, rather than the data itself. In this	manner, an external program may freely modify an element of the heap, given that it	possesses a pointer to said element (in an array-based heap, the addresses and the 	value in that address are not bound and thus may change during the heapify() operation).*/struct hnode { tuple     *d; };const int heapmin = 3;//const double tiny = -4294967296.0;class maxheap {private:	hnode    *A;					// maxheap array	int       heaplimit;			// first unused element of heap array	int		arraysize;			// size of array	bool		isempty;				// T if heap is empty; F otherwise	int		downsift(int i);		// sift A[i] down in heap	int		upsift  (int i);		// sift A[i] up in heap	int		left    (int i);		// returns index of left child	int		right   (int i);		// returns index of right child	int		parent  (int i);		// returns index of parent	void		grow();				// increase size of array A	void		shrink();				// decrease size of array A  public:	maxheap();					// default constructor	maxheap(int size);				// default constructor	~maxheap();					// default destructor		int		heapSize();							// returns heaplimit value	bool		heapIsEmpty();							// returns isempty value	tuple	*insertItem(const tuple newData);			// heap-inserts newData, returns the address of it	tuple	popMaximum();							// removes and returns heap max, reheapifies	tuple	returnMaximum();						// returns the heap max; no change to heap	void		printHeap();							// displays contents of the heap	void		printHeapTop10();						// displays top 10 entries in the heap	void		updateItem(tuple *address, tuple newData);   // updates the value of the tuple at address	void		updateItem(tuple *address, double newStored);// update only the stored value of tuple at address	void		deleteItem(tuple *address);				// remove an item from the heap	int		returnArraysize();						// 	int		returnHeaplimit();						// 	};// ------------------------------------------------------------------------------------// Max Heap methods// Constructor + Destructor -----------------------------------------------------------maxheap::maxheap() {	tuple *newtuple;	heaplimit = 1;							// first free location is A[1]	arraysize = heapmin+1;					// 	isempty   = true;						// heap is initially empty	A = new hnode [arraysize];				// allocate array for heap	for (int i=0; i<arraysize; i++) {			// initialize heap values		newtuple = new tuple;				// 		A[i].d = newtuple;					// 		A[i].d->m = -4294967296.0;			// a very negative value; unlikely to be a valid dQ		A[i].d->i = 0;						// 		A[i].d->j = 0;						// 		A[i].d->k = i;						// 	}}maxheap::maxheap(int size) {	tuple *newtuple;	heaplimit = 1;							// first free location is A[1]	arraysize = size+1;						// 	isempty   = true;						// heap is initially empty	A = new hnode [arraysize];				// allocate array for heap	for (int i=0; i<arraysize; i++) {			// initialize heap values		newtuple = new tuple;				// 		A[i].d = newtuple;					// 		A[i].d->m = -4294967296.0;			// a very negative value; unlikely to be a valid dQ		A[i].d->i = 0;						// 		A[i].d->j = 0;						// 		A[i].d->k = i;						// 	}}maxheap::~maxheap() {	for (int i=0; i<arraysize; i++) { delete A[i].d; }	// first delete the containers pointed to	delete [] A;									// then delete the list of pointers to containers}// Pop Maximum ------------------------------------------------------------------------tuple maxheap::popMaximum() {				// O(log k) time	tuple temp = returnMaximum();	deleteItem(A[1].d);	return temp;}// Return Maximum --------------------------------------------------------------------tuple maxheap::returnMaximum() {			// O(1) time	tuple temp;	temp.m = A[1].d->m;					// 	temp.i = A[1].d->i;					// 	temp.j = A[1].d->j;					// 	temp.k = A[1].d->k;					// grab A's data	return temp;}int maxheap::returnArraysize() { return arraysize; }int maxheap::returnHeaplimit() { return heaplimit; }// Heapification functions ------------------------------------------------------------int maxheap::downsift(int index) {			// O(log k) time	bool stopFlag  = false;	int L		= left(index);	int R		= right(index);	int swap;	tuple* temp;		while (!stopFlag) {		// check that both children are within the array boundaries		if ((L < heaplimit) && (R < heaplimit)) {			if (A[L].d->m > A[R].d->m) { swap = L; } else { swap = R; } // first choose larger of the children		} else { if (L < heaplimit) { swap = L; } else { break; } }		// only one child to consider				// now decide if need to exchange A[index] with A[swap]		if (A[index].d->m < A[swap].d->m) {			temp          = A[index].d;   // exchange pointers A[index] and A[swap]			A[index].d    = A[swap].d;    // 			A[index].d->k = index;		// note A[index].d's change of array location			A[swap].d     = temp;		// 			A[swap].d->k  = swap;		// note A[swap].d's change in array location						index = swap;				// update indices for next pass			L     = left(index);		// 			R     = right(index);		// 					} else { stopFlag = true; }	}	return index;						// return the new index location of downsifted element}int maxheap::upsift(int index) {			// O(log k) time	bool stopFlag = false;	int P         = parent(index);	tuple* temp;	while (!stopFlag) {		// decide if A[index] needs to move up in tree		if ((P > 0) && (A[index].d->m > A[P].d->m)) {			temp          = A[index].d;   // exchange A[index] and A[P]			A[index].d    = A[P].d;		// 			A[index].d->k = index;		// note A[index].d's change of array location			A[P].d        = temp;		// 			A[P].d->k     = P;			// note A[P].d's change of array location						index = P;				// update indices for next pass			P     = parent(index);		// 		} else { stopFlag = true; }	}	return index;}int  maxheap::left  (int index) { return 2*index;		}int  maxheap::right (int index) { return 2*index+1;    }int  maxheap::parent(int index) { return (int)index/2; }void maxheap::grow() {								// O(k) time	tuple	*newtuple;	hnode	*B;									// scratch space for expansion of A	B = new hnode [arraysize];						// 	for (int i=0; i<arraysize; i++) { B[i].d = A[i].d; }   // copy A into B	delete [] A;									// delete old array of addresses	A = new hnode [2*arraysize];						// grow A by factor of 2	for (int i=0; i<arraysize; i++) { A[i].d = B[i].d; }   // copy B into first half of A	for (int i=arraysize; i<(2*arraysize); i++) {		// initialize new heap values		newtuple  = new tuple;						// 		A[i].d    = newtuple;						// 		A[i].d->m = -4294967296.0;					// 		A[i].d->i = 0;								// 		A[i].d->j = 0;								// 		A[i].d->k = i;								// 	}										 	delete [] B;									// delete scratch space B	arraysize = 2*arraysize;							// update size of array	return;}void maxheap::shrink() {								// O(k) time	tuple	*newtuple;	hnode	*B;									// scratch space for contraction of A	B = new hnode [heaplimit];						// 	for (int i=0; i<heaplimit; i++) { B[i].d = A[i].d; }   // copy A into B	delete [] A;									// delete old array of addresses	A = new hnode [arraysize/2];						// shrink A by factor of 2	for (int i=0; i<heaplimit; i++) { A[i].d = B[i].d; }   // copy B into A	for (int i=heaplimit; i<(arraysize/2); i++) {		// initialize new heap values		newtuple  = new tuple;						// 		A[i].d    = newtuple;						// 		A[i].d->m = -4294967296.0;					// 		A[i].d->i = 0;								// 		A[i].d->j = 0;								// 		A[i].d->k = i;								// 	}										 	delete [] B;									// delete scratch space B	arraysize = arraysize/2;							// update size of array	return;}// Insert + Update Functions --------------------------------------------------------------tuple* maxheap::insertItem(const tuple newData) {			// O(log k) time	int index;	tuple *pointer;	if (heaplimit >= (arraysize-1)) { grow(); }  // if heap is full, grow by factor of 2	index		= heaplimit;			// 	A[index].d->m  = newData.m;			// copy newData onto the bottom of the heap	A[index].d->i  = newData.i;			// 	A[index].d->j  = newData.j;			// 	A[index].d->k  = index;				//	pointer		= A[index].d;			// store pointer to container	heaplimit++;						// note the larger heap	upsift(index);						// upsift new item up to proper spot	if  (heaplimit > 1) { isempty = false; }		return pointer;}void maxheap::updateItem(tuple *address, tuple newData) {   // O(log k) time	double oldm = address->m;	address->m = newData.m;						//   udpate the dQ stored	address->j = newData.j;						//   udpate the community to which to join	if (oldm > newData.m) { downsift(address->k); }   //   downsift if old value was larger	else				  { upsift(address->k);   }   //   upsift otherwise	return;}void maxheap::updateItem(tuple *address, double newStored) {	// O(log k) time	double oldm    = address->m;	address->m	= newStored;						// udpate the dQ stored	if (oldm > newStored) { downsift(address->k); }		// downsift if old value was larger	else				  { upsift(address->k);   }		// upsift otherwise	return;}void maxheap::deleteItem(tuple *address) {	tuple *swap;	int small = heaplimit-1;	int index = address->k;	if (heaplimit==2) {						// check if deleting last item in heap		A[1].d->m		= -4294967296.0;		// zero out root data		A[1].d->i		= 0;					// 		A[1].d->j		= 0;					// 		A[1].d->k		= 1;					// 		isempty		= true;				// note the heap's emptiness		heaplimit--;						// decrement size of heap to empty	} else {		A[index].d->m  = -4294967296.0;		// zero out the deleted item's data		A[index].d->i	= 0;					// 		A[index].d->j  = 0;					// 		swap			= A[index].d;			// swap this element with item at end of heap		A[index].d	= A[small].d;			// 		A[small].d	= swap;				// 		A[index].d->k  = index;				// note the change in locations		A[small].d->k  = small;				// 		heaplimit--;						// note change in heap size		downsift(index);					// downsift moved element to new location; O(log k)		if ((heaplimit/2 > heapmin) && (heaplimit == (arraysize/2))) { shrink(); } // shrink by factor of 2 if necessary	}	return;}bool maxheap::heapIsEmpty() { return isempty; }int  maxheap::heapSize()    { return heaplimit-1; }// Display Functions --------------------------------------------------------------------void maxheap::printHeap() {	for (int i=1; i<heaplimit; i++) {		cout << A[i].d <<"\t["<<A[i].d->k<<"]\tdQ = "<<A[i].d->m<<"\t"<<A[i].d->i<<" -> "<<A[i].d->j<<"\n"; }	return;}void maxheap::printHeapTop10() {	int limit;	if (heaplimit>10) { limit = 11; } else { limit = heaplimit; }	for (int i=1; i<limit; i++) {		cout << A[i].d <<"\t["<<A[i].d->k<<"]\tdQ = "<<A[i].d->m<<"\t"<<A[i].d->i<<" -> "<<A[i].d->j<<"\n"; }	return;}// ------------------------------------------------------------------------------------#endif

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美色电影| 午夜伊人狠狠久久| 中文字幕人成不卡一区| 国产91在线观看| 国产亚洲午夜高清国产拍精品| 久久99国产精品久久99| 欧美一级欧美一级在线播放| 青青草原综合久久大伊人精品优势| 欧美日韩国产影片| 日韩成人午夜电影| 精品av综合导航| 国产成人啪午夜精品网站男同| 中文字幕+乱码+中文字幕一区| 99视频精品在线| 一区二区三区鲁丝不卡| 欧美日精品一区视频| 日韩高清在线一区| 一区二区三区产品免费精品久久75| 精品国产一二三| 欧美一区二区在线免费观看| 色婷婷激情综合| 日韩激情一二三区| 久久久久99精品国产片| 99国产欧美久久久精品| 亚洲亚洲精品在线观看| 欧美精品一区二区三区蜜臀| 欧美日韩在线亚洲一区蜜芽| 99国产精品久久久| 成人av先锋影音| 午夜精品一区二区三区电影天堂| 亚洲人吸女人奶水| 日韩欧美国产综合一区| 欧美肥妇free| 97se亚洲国产综合自在线观| 国产成人午夜精品5599| 精品制服美女久久| 狠狠色丁香九九婷婷综合五月 | 欧美色男人天堂| 99久久精品国产导航| 成人免费av在线| 日韩激情在线观看| 首页亚洲欧美制服丝腿| 婷婷成人激情在线网| 婷婷开心激情综合| 免费观看一级特黄欧美大片| 日韩电影一区二区三区| 蜜臀久久99精品久久久画质超高清| 国产精品久久久久久福利一牛影视| 欧美丰满少妇xxxxx高潮对白| 欧美日本韩国一区| 日韩亚洲欧美综合| 在线视频国内一区二区| 国产69精品一区二区亚洲孕妇| 国产精品99久久久久久久vr| 日韩精品欧美精品| 久久福利资源站| 天天影视涩香欲综合网| 免费成人结看片| 国产传媒日韩欧美成人| 成人高清免费在线播放| 色噜噜狠狠成人中文综合| 丁香婷婷综合五月| 色综合久久中文字幕| 欧美性感一区二区三区| www.成人网.com| 91成人看片片| 91精品国产色综合久久久蜜香臀| 精品日韩一区二区| 日韩一区二区免费高清| 久久久99精品免费观看| 亚洲美女淫视频| 日韩不卡免费视频| 国产精品538一区二区在线| eeuss影院一区二区三区| 欧美亚洲动漫制服丝袜| 精品欧美久久久| 日韩一区有码在线| 日韩经典中文字幕一区| 成人性生交大片| 欧美日韩国产片| 亚洲国产精品成人综合色在线婷婷 | 亚洲色欲色欲www| 国产精品久久久久一区二区三区| 亚洲制服丝袜在线| 亚洲国产裸拍裸体视频在线观看乱了| 免费观看一级特黄欧美大片| av激情综合网| 日韩欧美国产三级| 亚洲视频中文字幕| 激情综合色综合久久| 91蜜桃传媒精品久久久一区二区| 成人av小说网| 日韩写真欧美这视频| 国产精品大尺度| 精品中文av资源站在线观看| 在线中文字幕一区二区| 久久精品人人做人人综合| 亚洲一区二区视频在线| 成人在线综合网| 一区二区三区丝袜| 国产成人av电影在线播放| 欧美日韩国产影片| 亚洲免费av高清| 国产精品一区二区久激情瑜伽| 欧美日韩1234| 亚洲码国产岛国毛片在线| 国产一区二区三区久久久 | 国产一区二区三区四区在线观看| 91精品1区2区| 国产精品每日更新在线播放网址| 综合av第一页| 国产成人高清视频| 欧美videos大乳护士334| 亚洲宅男天堂在线观看无病毒| 成人午夜激情片| 26uuu精品一区二区在线观看| 国产精品久久久久久久蜜臀| 精品一区二区三区久久| 91精品国产乱码久久蜜臀| 亚洲日本免费电影| av综合在线播放| 欧美国产国产综合| 国产黑丝在线一区二区三区| 日韩一级免费观看| 日韩制服丝袜av| 欧美精品久久久久久久久老牛影院| 樱桃国产成人精品视频| 老鸭窝一区二区久久精品| 91精品午夜视频| 日本一区二区三区电影| 亚洲va韩国va欧美va精品| 91福利在线观看| 一二三区精品视频| 色八戒一区二区三区| 亚洲伦理在线免费看| 国产亚洲欧美一区在线观看| 久久91精品久久久久久秒播| 欧美一级一区二区| 久久99精品国产| 久久精品在线免费观看| 成人午夜激情在线| 亚洲图片你懂的| 色94色欧美sute亚洲线路一久| 亚洲精品国产无天堂网2021| 日本精品一级二级| 亚洲国产一区二区三区| 欧美精品久久99久久在免费线| 视频在线在亚洲| 欧美变态凌虐bdsm| 国内国产精品久久| 中文无字幕一区二区三区| av高清不卡在线| 亚洲最新视频在线播放| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 亚洲欧美视频在线观看视频| av亚洲精华国产精华精华| 亚洲男女一区二区三区| 欧美三级视频在线| 久久激情五月婷婷| 欧美激情一区在线| 91片黄在线观看| 丝袜亚洲另类欧美| 久久综合九色综合欧美就去吻| 成人精品小蝌蚪| 亚洲一区二区精品久久av| 欧美一区二区黄| 高清久久久久久| 在线观看日韩电影| 日韩二区三区四区| 久久久久久久久蜜桃| 91玉足脚交白嫩脚丫在线播放| 亚洲v日本v欧美v久久精品| 欧美精品一区二区在线观看| 99国产精品国产精品毛片| 日韩精品一二三区| 国产精品久久久久久久久晋中 | 日本高清不卡aⅴ免费网站| 日韩国产一区二| 国产精品久久久久久久久久免费看| 在线亚洲一区观看| 韩国v欧美v亚洲v日本v| 亚洲人成精品久久久久| 精品免费视频一区二区| 91在线观看地址| 开心九九激情九九欧美日韩精美视频电影 | 欧美电影在线免费观看| 成人精品小蝌蚪| 免费亚洲电影在线| 亚洲免费观看高清完整版在线观看熊 | 99久久免费国产| 美女在线一区二区| 亚洲精品视频免费观看| 久久嫩草精品久久久久| 欧美日韩成人综合在线一区二区 | 欧美日韩dvd在线观看| www.爱久久.com| 精品综合久久久久久8888| 亚洲一级电影视频| 国产精品成人一区二区三区夜夜夜| 91精品麻豆日日躁夜夜躁|