Skip to content

Commit f99c2b6

Browse files
authored
Merge pull request #13 from Sitaras/debugCluster2
Debug/Test cluster
2 parents a59b8cd + 838d0c1 commit f99c2b6

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

Clustering/clustering.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ void clusteringLSH(List vecList,int numOfClusters,int l,FILE* fptr){
244244
}
245245
props = calloc(numOfVecs,sizeof(double));
246246

247-
hashTableSize=numOfVecs/16;
247+
hashTableSize=numOfVecs/32;
248248
LSH lsh = initializeLSH(l);
249249
for(int i=0;i<numOfVecs;i++){
250250
initializeClusterInfo(vectors[i]);
@@ -366,7 +366,7 @@ void reverseAssignmentHypercube(HyperCube cube,Vector *vectors,Vector *clusters,
366366
List confList=initializeList();
367367
for(int i=0;i<numOfClusters;i++){
368368
radiusNeigborHypercubeClustering(cube,clusters[i],clustersHt[i],radius,probes,m,i,&confList,&assignCounter,iteration);
369-
printf("******* ---- ASSINGED ITEMS = %d\n",assignCounter);
369+
printf("******* ---- ASSINGED ITEMS = %d | Cluster %d\n",assignCounter,i+1);
370370
}
371371
listSolveRangeConflicts(confList,clustersHt,clusters,numOfClusters,d,iteration);
372372
printf("---- ASSINGED ITEMS = %d\n",assignCounter);
@@ -467,6 +467,7 @@ void clusteringHypercube(List vecList,int numOfClusters,int m,int probes,FILE* f
467467

468468
fprintf(fptr, "clustering_time: %f seconds\n",cluster_time);
469469
fflush(fptr);
470+
fflush(stdout);
470471

471472
printf("- COMPUTING SILHOUETTES FOR CLUSTERS\n");
472473
double stotal = 0.0;

cluster.conf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
number_of_clusters: 4
2-
number_of_vector_hash_tables: 6
2+
number_of_vector_hash_tables: 5
33
number_of_vector_hash_functions: 6
4-
max_number_M_hypercube: 100
5-
number_of_hypercube_dimensions: 5
6-
number_of_probes: 15
4+
max_number_M_hypercube: 500
5+
number_of_hypercube_dimensions: 4
6+
number_of_probes: 16

hashTable/hashTable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void htPrint(const HashTable ht){
8686
void htPrintClustering(const HashTable ht,FILE* fptr){
8787
for (int i=0;i<ht->buckets;i++){
8888
listPrintClusteringInFile(ht->table[i].head,fptr);
89-
if(i!=ht->buckets-1)
89+
if(i!=ht->buckets-1 && (ht->table[i].head!=NULL))
9090
fprintf(fptr,", ");
9191
}
9292
printf("\n\n");

hashTable/hashTableList/hashTableList.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void listPrint(List list){
121121
}
122122

123123
void listPrintClusteringInFile(List list,FILE* fptr){
124-
if(list==NULL){ printf("List Empty!\n"); return;}
124+
if(list==NULL){ return;}
125125
List temp=list;
126126
while(temp!=NULL){
127127
printVectorIdInFileNoNewline(temp->v,fptr);
@@ -426,7 +426,8 @@ void listFindNeighborsInRadiusClustering(List list,int centroidIndex,List* confL
426426
if(id==(temp->vector_ID)){
427427
if(assignedToCluster(temp->v) && (getAssignedIteration(temp->v)==iteration)){
428428
int assignedCluster = getAssignedCluster(temp->v);
429-
if(assignedCluster==centroidIndex || (((int)getAssignedAtRadius(temp->v))!=radius)){
429+
// if(assignedCluster==centroidIndex || (((int)getAssignedAtRadius(temp->v))!=radius)){
430+
if(assignedCluster==centroidIndex || (((int)getAssignedAtRadius(temp->v))<-1)){
430431
temp=temp->next;
431432
continue;
432433
}else{
@@ -470,7 +471,8 @@ void listFindNeighborsInRadiusClusteringCube(List list,int centroidIndex,List* c
470471
// then
471472
// check if vector has already been assigned at the some cluster (check the centroid index)
472473
// or if vector has already been assigned previously in cluster at a search with different radius
473-
if(assignedCluster==centroidIndex || (getAssignedAtRadius(temp->v)!=radius)){
474+
if(assignedCluster==centroidIndex || (getAssignedAtRadius(temp->v)<-1.0 )){
475+
// if(assignedCluster==centroidIndex || (getAssignedAtRadius(temp->v)!=radius )){
474476
// ok, then skip it
475477
temp=temp->next;
476478
continue;
@@ -484,10 +486,10 @@ void listFindNeighborsInRadiusClusteringCube(List list,int centroidIndex,List* c
484486
}
485487
}
486488
else{
487-
htRangeInsert(storeNeighbors,temp->v,temp->vector_ID,d);
488489
setAssignedCluster(temp->v,centroidIndex);
489490
setAssignedIteration(temp->v,iteration);
490491
setAssignedAtRadius(temp->v,radius);
492+
htRangeInsert(storeNeighbors,temp->v,temp->vector_ID,d);
491493
(*assignCounter)++;
492494
}
493495
}

0 commit comments

Comments
 (0)