Skip to content

Commit

Permalink
small pathc
Browse files Browse the repository at this point in the history
  • Loading branch information
blaise-muhirwa committed Dec 8, 2023
1 parent c154a05 commit 902900d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions flatnav/Index.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ template <typename dist_t, typename label_t> class Index {
*/
Index(std::shared_ptr<DistanceInterface<dist_t>> dist,
std::vector<std::vector<uint32_t>> &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)) {
Expand All @@ -90,13 +90,14 @@ template <typename dist_t, typename label_t> 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;
}

}
}
}
Expand Down
10 changes: 10 additions & 0 deletions tools/load_mtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -80,6 +89,7 @@ int main() {
float *queries = queryfile.data<float>();
int *gtruth = truthfile.data<int>();


std::cout << "constructing the index" << std::endl;
auto distance = std::make_shared<flatnav::SquaredL2Distance>(128);
std::unique_ptr<flatnav::Index<flatnav::SquaredL2Distance, int>> index =
Expand Down

0 comments on commit 902900d

Please sign in to comment.