From 601b48aac1bc8f767e9515b13427b10b4b0aa760 Mon Sep 17 00:00:00 2001 From: "dario.genga" <dario.genga@etu.hesge.ch> Date: Sat, 18 Jun 2022 21:42:57 +0200 Subject: [PATCH] Update console printf --- kmeans.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/kmeans.c b/kmeans.c index f900603..eadded0 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) { -- GitLab