}
map
while(map_it!=items_count.end()) //Êä³öºòÑ¡1Ï {
cout<<\ map_it++; }
cout<<\ getchar();
map_it=items_count.begin();
cout<<\Ƶ·±1Ï(minsup=2):\
while(map_it!=items_count.end()) //Ƶ·±1Ï {
if(map_it->second>minsup) //Ö§³Ö¶È´óÓÚ2 {
cout.setf(ios::fixed); cout<<\Ö§³Ö¶È:\>second< item.push_back(map_it->first); frequentvec.push_back(item); //²åÈëºòÑ¡ÏµÄvectorÖÐ item.clear(); } map_it++; } if(!frequentvec.empty()) //ÅжÏƵ·±ÏÊÇ·ñΪ¿Õ£¬Îª¿ÕÔòÍ˳ö { cout<<\ getchar(); int round=1; //Éú³ÉºòÑ¡ÏÂÖ´Î int found; //ÊÇ·ñ°üº¬ÓзÇƵ·±µÄ×Ó¼¯,Ϊ±íʾº¬ÓУ¬ÓеĻ°½øÐмôÖ¦ string tempstr; vector //Éú³ÉÏÂÒ»ÂֵĺòÑ¡Ï vector for(vector for(vector found=0; item=mergeItem(frequentvec[st1],frequentvec[st2],round); //µ÷Óú¯ÊýºÏ ²¢Éú³ÉÏÂÒ»ÂֵĺòÑ¡Ï if(!item.empty()&&!isExist(item,candidatevec)) //Èô¾¹ýÅжϴ¦Àíºó·µ»ØµÄvector²»Îª¿ÕÇÒ»¹²»´æÔÚ¸ÃÏ£¬Ôò×÷ΪºòÑ¡Ï¼ÓÈëºòÑ¡vectorÖÐ { ////////ʵÏÖ¼ôÖ¦////////////////////////// string teststr; int testint; tempvec=item; sort(tempvec.begin(),tempvec.end()); while(next_permutation(tempvec.begin(),tempvec.end())) //±éÀúËùÓеÄ×éºÏ { for(vector tempst=0;tempst!=tempvec.size();tempst++) //Æ´½Ó³ö¸Ã×Ö·û´®×éºÏ { tempstr+=tempvec[tempst]; } for(map tempit=items_count.begin();tempit!=items_count.end();tempit++) { if(tempit->second if(tempstr.find(tempit->first)!=string::npos) //±íʾ°üº¬ÓзÇƵ·±×ÓÏ { found=1; teststr=tempit->first; testint=tempit->second; break; } } } tempstr.erase(); if(found) //°üº¬·ÇƵ·±×ÓÏ { break; } } if(!found) //Ö»Óв»°üº¬ÓзÇƵ·±×ÓÏ²Å¼ÓÈëºòÑ¡ÏÖУ¬·ñÔò¼ôÖ¦µô candidatevec.push_back(item); found=0; //ÖØÖà } } } frequentvec.clear(); //Çå³ýÉÏÒ»ÂÖµÄƵ·±Ï round++; cout<<\ºòÑ¡\Ï:\ for(vector { cout<<\ for(vector cout< cout<<\ } if(candidatevec.empty()) //ºòÑ¡ÏΪ¿Õ { cout<<\ºòÑ¡\ÏΪ¿Õ!\ } int flag; //±ê¼Çij¸öÏÔÚijÌõÊÂÎñÖÐÊÇ·ñ³öÏÖ£¬³öÏÖΪ1£¬²»³öÏÖΪ0 int count; //ͳ¼Æij¸öÏ뼯ÔÚÕû¸ö½»Ò×µÄÊÂÎñ¼¯ÖгöÏֵĴÎÊý string tempstr; //ÁÙʱstring£¬ÓÃÓÚ´®½Ó¸÷¸öÏî³ÉÒ»¸ö×Ö·û´® int mark; //Ϊ±ÜÃâÖ´ÐжàÓàµÄ×Ö·û´®´®½Ó¹¤×÷ for(vector { mark=1; count=0; for(vector flag=1; //³õʼ»¯Îª1£¬±í³öÏÖ for(vector if(bitmap[sy][candidatevec[sx].at(sz)]==0) //´æÔÚijһ¸ö×ÓÏî²»´æÔÚ£¬Ôòû³öÏÖÏ { flag=0; } if(mark==1) //Ö»´®½ÓÒ»´Î { tempstr+=candidatevec[sx].at(sz); //´®½Ó×Ö·û´® } } if(flag) //flagÈÔȻΪ£¬±íʾ¸ÃÏÔÚ¸ÃÌõÊÂÎñÖгöÏÖÁË£¬¼ÆÊý¼Ó { count++; } mark++; } if(count>minsup) //Ö§³Ö¶È´óÓÚ2 { frequentvec.push_back(candidatevec[sx]); //²åÈëƵ·±Ï } items_count[tempstr]=count; //¶ÔÓ¦¸ÃÏµÄ¼ÆÊýÖµ sort(candidatevec[sx].begin(),candidatevec[sx].end()); //ÅÅÐò string tempstr2; while(next_permutation(candidatevec[sx].begin(),candidatevec[sx].end())) //È¡ÏÂÒ»ÅÅÁÐ×éºÏ { for(vector tempst=0;tempst!=candidatevec[sx].size();tempst++) //Æ´½Ó³ö¸Ã×Ö·û´®×éºÏ { tempstr2+=candidatevec[sx][tempst]; } items_count[tempstr2]=count; //¶ÔÓ¦¸ÃÏµÄ¼ÆÊýÖµ tempstr2.erase(); } tempstr.erase(); } cout<<\ getchar(); if(!frequentvec.empty()) //Ƶ·±Ï²»Îª¿Õ { cout<<\Ƶ·±\Ï(minsup=2):\ for(int sx=0;sx!=frequentvec.size();++sx) //Êä³öƵ·±Ï { cout.setf(ios::fixed); cout<<\ for(vector cout< tempstr+=frequentvec[sx].at(sz); //´®½Ó×Ö·û´® }