Skip to content
Snippets Groups Projects
Commit 21de63b2 authored by Boris Stefanovic's avatar Boris Stefanovic
Browse files

ADD: cluster

parent 3aecce5e
Branches
No related tags found
No related merge requests found
//
// by Boris Stefanovic on 01/06/22
//
#include "cluster.h"
#include "vector.h"
cluster_point_int_t* cluster_point_int_create(vector_int_t* vector) {
cluster_point_int_t* elem = malloc(sizeof(cluster_point_int_t));
if (NULL == elem) return NULL;
elem->vector = vector;
elem->cluster = NULL;
}
//
// by Boris Stefanovic on 01/06/22
//
#ifndef PROG_KMEANS_CLUSTER_H
#define PROG_KMEANS_CLUSTER_H
#include "vector.h"
typedef vector_int_t cluster_int_t; // a cluster may be represented by its center
typedef struct cluster_point_int {
vector_int_t* vector;
cluster_int_t* cluster; // justified by "many-to-one" relationship and several passes over all points
} cluster_point_int_t;
cluster_point_int_t* cluster_point_int_create(vector_int_t* vector);
#endif //PROG_KMEANS_CLUSTER_H
//
// by Boris Stefanovic on 01/06/22
//
#include "kmeans.h"
#include "cluster.h"
//
// by Boris Stefanovic on 01/06/22
//
#ifndef PROG_KMEANS_KMEANS_H
#define PROG_KMEANS_KMEANS_H
//
#endif //PROG_KMEANS_KMEANS_H
......@@ -58,10 +58,11 @@ ll_vint_t* get_vector_list(FILE* ifile, const size_t dim) {
while (getline(&line, &len, ifile) != -1) {
if (len != 0) {
vector_int_t* vector = line_to_vector_int(line, dim);
//TODO
ll_vint_append(list, vector);
free(line);
}
}
return list;
}
......@@ -89,15 +90,9 @@ int main(int argc, char** argv) {
printf("NUMBER OF CLUSTERS MUST BE STRICTLY POSITIVE !\n");
return EXIT_FAILURE;
}
char* line = NULL;
size_t len = 0;
while (getline(&line, &len, ifile) != -1) {
if (len != 0) {
vector_int_t* vector = line_to_vector_int(line, dim);
//TODO
free(line);
}
}
ll_vint_t* list = get_vector_list(ifile, dim);
// ALGORITHM
// TODO
// WRITE
FILE* ofile = opath != NULL ? fopen(opath, "w") : stdout;
// TODO
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment