You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
895 B

1 year ago
1 year ago
1 year ago
1 year ago
  1. #pragma once
  2. #include <stdio.h>
  3. #include "utils.h"
  4. // you can add more structures here or modify existing structrues.
  5. typedef struct HNSWGraph
  6. {
  7. size_t layers_num; // number of layers
  8. } HNSWGraph;
  9. typedef struct HNSWContext
  10. {
  11. size_t dim; // dimension of dataset
  12. size_t len; // size of dataset
  13. VecData *data; // vectors will be loaded into this array
  14. HNSWGraph *graph; // graph of HNSW
  15. } HNSWContext;
  16. // you can declare some help functions here, and implement them in 'hnsw.c'
  17. // public functions here
  18. // Please do not modify these function signatures!
  19. // To simply our program, we do not consider reclaiming memory space here.
  20. // TODO: Please implement these functions according to HNSW algorithm.
  21. HNSWContext *hnsw_init_context(const char *filename, size_t dim, size_t len);
  22. void hnsw_approximate_knn(HNSWContext *ctx, VecData *q, int *results, int k);