|
#pragma once
|
|
|
|
#include <stdio.h>
|
|
#include "utils.h"
|
|
|
|
// you can add more structures here or modify existing structrues.
|
|
|
|
typedef struct HNSWGraph
|
|
{
|
|
size_t layers_num; // number of layers
|
|
} HNSWGraph;
|
|
|
|
typedef struct HNSWContext
|
|
{
|
|
size_t dim; // dimension of dataset
|
|
size_t len; // size of dataset
|
|
VecData *data; // vectors will be loaded into this array
|
|
HNSWGraph *graph; // graph of HNSW
|
|
} HNSWContext;
|
|
|
|
// you can declare some help functions here, and implement them in 'hnsw.c'
|
|
|
|
// public functions here
|
|
// Please do not modify these function signatures!
|
|
// To simply our program, we do not consider reclaiming memory space here.
|
|
// TODO: Please implement these functions according to HNSW algorithm.
|
|
HNSWContext *hnsw_init_context(const char *filename, size_t dim, size_t len);
|
|
void hnsw_approximate_knn(HNSWContext *ctx, VecData *q, int *results, int k);
|