diff --git a/kmeans.c b/kmeans.c index f90060394d28c7391bf89b04d0c479888e7f01c4..eadded0900dcae82d914065f75ecf260f3136c34 100644 --- a/kmeans.c +++ b/kmeans.c @@ -306,7 +306,9 @@ void assign_points_to_cluster(point* p, kmeans* universe) { void start_clustering(kmeans* universe) { bool clustering_in_progress = false; init_clusters(universe); + int iteration = 1; + printf("\nStarting clustering...\n"); do { clustering_in_progress = false; @@ -316,18 +318,14 @@ void start_clustering(kmeans* universe) { } // Compute the new center of gravity for each cluster - printf("Clusters positions...\n"); for (int i = 0; i < universe->k; i++) { if (compute_center_of_gravity(universe->clusters_array[i], universe)) { clustering_in_progress = true; } - printf("Cluster %d position : ", i); - for (int j = 0; j < universe->dimensions; j++) { - printf("%0.2f, ", universe->clusters_array[i]->centroid->value[j]); - } - printf("\n"); } + iteration++; } while (clustering_in_progress); + printf("Clustering ended after %d iterations.\n", iteration); } void destroy_point(point* p) {