Skip to content
Snippets Groups Projects
Commit 601b48aa authored by dario.genga's avatar dario.genga
Browse files

Update console printf

parent ff0f8b35
No related branches found
No related tags found
No related merge requests found
......@@ -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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment