double c_nodes_jacc(int_matrix & ten, int_matrix & en, int dim) {
	
	
	// this function does a best match based on the jaccard index.
	// note that it should be weighted on the cluster size (I believe)
	
	
	deque<deque<int> > mems;
	
	deque<int> first;
	for(int i=0; i<dim; i++)
		mems.push_back(first);
	
	for (int ii=0; ii<int(ten.size()); ii++)
		for(int i=0; i<int(ten[ii].size()); i++)
			mems[ten[ii][i]].push_back(ii);
	
	double global_overlap=0;
	RANGE_loop(k, en) {
		
		deque<int> & c = en[k];
		
		map<int, int> com_ol;		// it maps the index of the ten into the overlap with en[k]
		
		RANGE_loop(i, c) {
			
			for(int j=0; j<int(mems[c[i]].size()); j++)
				int_histogram(mems[c[i]][j], com_ol);
		}
		
		double max_jac=0;
		for(map<int, int>::iterator itm=com_ol.begin(); itm!=com_ol.end(); itm++) {
			
			set<int> s1;
			set<int> s2;
			
			deque_to_set(c, s1);
			deque_to_set(ten[itm->first], s2);
			
			double jc=jaccard(s1, s2);
			cout<<"jc: "<<jc<<endl;
			max_jac=max(max_jac, jc);
			
		}
		
		global_overlap+=max_jac;
		cout<<"========== "<<global_overlap<<endl;
	}
Beispiel #2
0
void from_int_matrix_and_deque_to_deque(int_matrix & its_submodules, const DI & A, DI & group) {
	
	// it merges A and its_submodules in group
	
	set<int> all_the_groups;
	for(UI i=0; i<its_submodules.size(); i++) {
		
		
		for(UI j=0; j<its_submodules[i].size(); j++)
			all_the_groups.insert(its_submodules[i][j]);
		
	}
	
	for(UI i=0; i<A.size(); i++)
		all_the_groups.insert(A[i]);
	
	
	set_to_deque(all_the_groups, group);
	


}