psuedo -...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
__gnu_cxx::hash_map<string,pair<int,int>index;//file,(index in f.dist, index in clusters) vector<pair<info, vector <files> > > clusters; //keep in mind that from similarity the f vector should be lexi //put files in its own cluster for(int x = 0; x < size; ++x) { info i; i.diam = 0; vector<files> v; v.push_back(f[x]); pair<info,vector<files> > tmp; tmp = make_pair(i,v); clusters.push_back(tmp); index.insert(make_pair(f[x].name,make_pair(x,x))); } int csize = clusters.size(); int next = 0; int merger; //cluster that I will merge with int max_diam; while(csize > K) { string file = f[next]; //which file is next to look at where = index.find(file);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
int spot = (where->second).second; //in which cluster this file is in pair<info, vector <files> > cluster_to_merge = clusters[spot]; for(int x = 0; x < csize; ++x) { pair<info, vector <files> > merge_with = clusters[x]; if(cluster_to_merge == merge_with) continue; else { string file1 = merge_with.second[0].name; d1 = index.find(file1); int other_cluster = (d1->second).first; max_diam = cluster_to_merge.second[0].dist[other_cluster]; for(unsigned int a = 0; a < cluster_to_merge.second.size(); ++a) { for(unsigned int b = 1; b < merge_with.second.size(); ++b) { file1 = merge_with.second[b].name; d1 = index.find(file1); other_cluster = (d1->second).first; int tmp_diam = _to_merge.second[a].dist[other_cluster]; if(tmp_diam > max_diam) { max_diam = tmp_diam; } }//b loop if(a == 0) cluster_to_merge.first.diam = max_diam; else {
Background image of page 2
if(cluster_to_merge.first.diam < max.diam)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/17/2008 for the course EECS 280 taught by Professor Noble during the Fall '08 term at University of Michigan.

Page1 / 10

psuedo -...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online