diff --git a/flatnav/Index.h b/flatnav/Index.h index beab3cf..b5ef4fe 100644 --- a/flatnav/Index.h +++ b/flatnav/Index.h @@ -65,7 +65,7 @@ template class Index { */ Index(std::shared_ptr> dist, std::vector> &outdegree_table) - : _M(outdegree_table[0].size()), _max_node_count(outdegree_table.size()), + : _M(32), _max_node_count(outdegree_table.size()), _cur_num_nodes(0), _distance(dist), _visited_nodes(outdegree_table.size() + 1), _outdegree_table(std::move(outdegree_table)) { @@ -90,13 +90,14 @@ template class Index { for (node_id_t node = 0; node < _outdegree_table.value().size(); node++) { node_id_t *links = getNodeLinks(node); for (int i = 0; i < _M; i++) { - if (_outdegree_table.value()[node].size() < _M) { + if (i >= _outdegree_table.value()[node].size()) { links[i] = node; } else { auto linkvalue = _outdegree_table.value()[node][i]; links[i] = linkvalue; } + } } } diff --git a/tools/load_mtx.cpp b/tools/load_mtx.cpp index 7ba685a..d318ea1 100644 --- a/tools/load_mtx.cpp +++ b/tools/load_mtx.cpp @@ -52,6 +52,15 @@ Graph loadGraphFromMatrixMarket(const char *filename) { return graph; } +void printVector(float* vector) { + for (int i = 0; i < 128; i++) { + std::cout << vector[i] << " "; + } + std::cout << std::endl; +} + + + int main() { // Replace with your filename const char *ground_truth_file = @@ -80,6 +89,7 @@ int main() { float *queries = queryfile.data(); int *gtruth = truthfile.data(); + std::cout << "constructing the index" << std::endl; auto distance = std::make_shared(128); std::unique_ptr> index =