Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Clustering/clustering.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void reverseAssignmentLSH(LSH lsh,Vector *vectors,Vector *clusters,Vector *oldCl
for(int i=0;i<numOfClusters;i++){
radiusNeigborsClustering(lsh,clusters[i],radius,clustersHt[i],i,&confList,&assignCounter,iteration);
}
listSolveRangeConflicts(confList,clustersHt,clusters,numOfClusters,d);
listSolveRangeConflicts(confList,clustersHt,clusters,numOfClusters,d,iteration);
printf("---- ASSINGED ITEMS = %d\n",assignCounter);
// manage the conflicts
if(confList==NULL)
Expand Down Expand Up @@ -368,7 +368,7 @@ void reverseAssignmentHypercube(HyperCube cube,Vector *vectors,Vector *clusters,
radiusNeigborHypercubeClustering(cube,clusters[i],clustersHt[i],radius,probes,m,i,&confList,&assignCounter,iteration);
printf("******* ---- ASSINGED ITEMS = %d\n",assignCounter);
}
listSolveRangeConflicts(confList,clustersHt,clusters,numOfClusters,d);
listSolveRangeConflicts(confList,clustersHt,clusters,numOfClusters,d,iteration);
printf("---- ASSINGED ITEMS = %d\n",assignCounter);
// manage the conflicts
if(confList==NULL)
Expand Down Expand Up @@ -453,6 +453,7 @@ void clusteringHypercube(List vecList,int numOfClusters,int m,int probes,FILE* f
reverseAssignmentHypercube(cube,vectors,clusters,oldClusters,clustersHt,numOfClusters,countLSH,m,probes,&firstTime);

firstIterLSH=FALSE;

}

clock_t cluster_end = clock();
Expand Down
2 changes: 1 addition & 1 deletion Hypercube/hypercube.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ void radiusNeigborHypercube(HyperCube hc,Vector q,double radius,int hammingDist,



void searchForHammingDistanceRadiusClustering(HyperCube hc,Vector v,int *v_index,int hammingDist,int startFrom,HashTable vecsInRadius,int *numOfSearched,int maxToSearch,int radius,int *nodesSearched,int probes,int centroidIndex,List* confList,int *assignCounter,int iteration){
void searchForHammingDistanceRadiusClustering(HyperCube hc,Vector v,int *v_index,int hammingDist,int startFrom,HashTable vecsInRadius,int *numOfSearched,int maxToSearch,double radius,int *nodesSearched,int probes,int centroidIndex,List* confList,int *assignCounter,int iteration){
if(hammingDist<=0){
int new_index = binaryArrayToDecimal(v_index,new_dimension);
htFindNeighborsInRadiusClusteringCube(hc->hypercube,new_index,centroidIndex,confList,vecsInRadius,v,d,radius,numOfSearched,maxToSearch,assignCounter,iteration);
Expand Down
6 changes: 3 additions & 3 deletions cluster.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
number_of_clusters: 4
number_of_vector_hash_tables: 7
number_of_vector_hash_functions: 4
max_number_M_hypercube: 100
number_of_vector_hash_tables: 6
number_of_vector_hash_functions: 6
max_number_M_hypercube: 10000
number_of_hypercube_dimensions: 5
number_of_probes: 15
2 changes: 1 addition & 1 deletion hashTable/hashTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void htFindNeighborsInRadiusClustering(HashTable ht,int index,int centroidIndex,
listFindNeighborsInRadiusClustering(ht->table[index].head,centroidIndex,confList,storeNeighbors,q,d,id,radius,assignCounter,iteration);
}

void htFindNeighborsInRadiusClusteringCube(HashTable ht,int index,int centroidIndex,List* confList,HashTable storeNeighbors,Vector q,int d,int radius,int *numOfSearched,int maxToSearch,int *assignCounter,int iteration){
void htFindNeighborsInRadiusClusteringCube(HashTable ht,int index,int centroidIndex,List* confList,HashTable storeNeighbors,Vector q,int d,double radius,int *numOfSearched,int maxToSearch,int *assignCounter,int iteration){
listFindNeighborsInRadiusClusteringCube(ht->table[index].head,centroidIndex,confList,storeNeighbors,q,d,radius,numOfSearched,maxToSearch,assignCounter,iteration);
}

Expand Down
2 changes: 1 addition & 1 deletion hashTable/hashTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int htDeleteNode(HashTable,int);
void htFindNearestNeighbor(HashTable ,int ,Vector ,Vector *,double *,int ,int );
void htKFindNearestNeighbors(HashTable, int, Vector, Vector *, double *, int ,int ,int );
void htFindNeighborsInRadiusClustering(HashTable ,int ,int ,List* ,HashTable ,Vector ,int ,int ,int ,int *,int );
void htFindNeighborsInRadiusClusteringCube(HashTable ,int ,int ,List* ,HashTable ,Vector ,int ,int ,int *,int ,int *,int );
void htFindNeighborsInRadiusClusteringCube(HashTable ,int ,int ,List* ,HashTable ,Vector ,int ,double ,int *,int ,int *,int );
void htFindNeighborsInRadius(HashTable ,int ,HashTable ,Vector ,int ,int ,int );
void htRangeInsert(HashTable , Vector ,int ,int );

Expand Down
Binary file modified hashTable/hashTable.h.gch
Binary file not shown.
24 changes: 18 additions & 6 deletions hashTable/hashTableList/hashTableList.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,10 @@ void listFindNeighborsInRadiusClustering(List list,int centroidIndex,List* confL
}
}

void listFindNeighborsInRadiusClusteringCube(List list,int centroidIndex,List* confList,HashTable storeNeighbors,Vector q,int d,int radius,int *numOfSearched,int maxToSearch,int *assignCounter,int iteration){
void listFindNeighborsInRadiusClusteringCube(List list,int centroidIndex,List* confList,HashTable storeNeighbors,Vector q,int d,double radius,int *numOfSearched,int maxToSearch,int *assignCounter,int iteration){
if(list==NULL){ return;}
List temp=list;
int count=0;
while(temp!=NULL){
if((*numOfSearched)>=maxToSearch){
return;
Expand All @@ -465,11 +466,12 @@ void listFindNeighborsInRadiusClusteringCube(List list,int centroidIndex,List* c
if(dist<=radius){
if(assignedToCluster(temp->v) && (getAssignedIteration(temp->v)==iteration)){
int assignedCluster = getAssignedCluster(temp->v);
if(assignedCluster==centroidIndex || (((int)getAssignedAtRadius(temp->v))!=radius)){
if(assignedCluster==centroidIndex || (getAssignedAtRadius(temp->v)!=radius)){
temp=temp->next;
continue;
}else{
*confList=listUniqueInsert(*confList,temp->v,-1);
*confList=listInsert(*confList,temp->v,-1);
count++;
temp=temp->next;
continue;
}
Expand All @@ -483,16 +485,21 @@ void listFindNeighborsInRadiusClusteringCube(List list,int centroidIndex,List* c
}
temp=temp->next;
}
// printf("-*-* INSIDE CONFS = %d\n",count );
}

void listSolveRangeConflicts(List conflictList,HashTable *clustersHt,Vector *clusters,int numOfClusters,int d){
void listSolveRangeConflicts(List conflictList,HashTable *clustersHt,Vector *clusters,int numOfClusters,int d,int iteration){
if(conflictList==NULL){ return;}
List temp=conflictList;
int count = 0;
int countreal =0;
while(temp!=NULL){
if(getAssignedAtRadius(temp->v)<-1){
count++;
if(getAssignedAtRadius(temp->v)<-1.0){
temp=temp->next;
continue;
}
countreal++;
htRangeDelete(clustersHt[getAssignedCluster(temp->v)],temp->v,temp->vector_ID,d);
double minDist = DBL_MAX;
int closestCentroid = -1;
Expand All @@ -505,10 +512,15 @@ void listSolveRangeConflicts(List conflictList,HashTable *clustersHt,Vector *clu
}
htRangeInsert(clustersHt[closestCentroid],temp->v,temp->vector_ID,d);
setAssignedCluster(temp->v,closestCentroid);
setAssignedAtRadius(temp->v,-2);
setAssignedAtRadius(temp->v,-3.0);
setAssignedIteration(temp->v,iteration);
temp=temp->next;

}

printf("--- COUNFLICTS == %d\n",count);
printf("--- REAL COUNFLICTS == %d\n",countreal);

}

void listFindNeighborsInRadiusCube(List list,HashTable storeNeighbors,Vector q,int d,int radius,int *numOfSearched,int maxToSearch){
Expand Down
4 changes: 2 additions & 2 deletions hashTable/hashTableList/hashTableList.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ void listFindNearestNeighbor(List ,Vector ,Vector *,double *,int ,int );
void listFindKNearestNeighbors(List, Vector, Vector *, double *, int,int ,int );
void listFindNeighborsInRadius(List ,HashTable ,Vector ,int ,int ,int );
void listFindNeighborsInRadiusClustering(List ,int ,List* ,HashTable ,Vector ,int ,int ,int ,int *,int );
void listFindNeighborsInRadiusClusteringCube(List ,int ,List* ,HashTable ,Vector ,int ,int ,int *,int ,int *,int );
void listFindNeighborsInRadiusClusteringCube(List ,int ,List* ,HashTable ,Vector ,int ,double ,int *,int ,int *,int );

void listFindNearestNeighborCube(List ,Vector ,Vector *,double *,int ,int *,int );
void listFindKNearestNeighborsCube(List ,Vector ,Vector *,double *,int ,int ,int *,int );
void listFindNeighborsInRadiusCube(List ,HashTable ,Vector ,int ,int ,int *,int );

Vector listMeanOfCluster(List ,int );
void listSolveRangeConflicts(List ,HashTable *,Vector *,int ,int );
void listSolveRangeConflicts(List ,HashTable *,Vector *,int ,int ,int );
double *listSumOfVectors(List ,int ,int *);
double listFindSumOfDistancesOfVector(List ,Vector ,int *,int );
void listComputeAverageDistOfEveryPointOfCluster(List *,int ,HashTable *,int ,Vector *,int ,double *,double *,int *,int );
Expand Down
Binary file modified hashTable/hashTableList/hashTableList.h.gch
Binary file not shown.
Loading