aaalgo / kgraph

A library for k-nearest neighbor search
BSD 2-Clause "Simplified" License
383 stars 85 forks source link

graph construction #18

Closed cestas closed 6 years ago

cestas commented 6 years ago

hi, I am using kgraph for a fast KNN graph construction. I used to use scikit learn KNN_graph and get a csr sparse matrix with weighted edges (used L2 distance). I was wondering if it is possible to get a similar KNN Graph representation using kgraph (using python api). I could otherwise use query to find the K nearest neighbor indices and then compute the L2 distances based on my original input data which has the coordinates of the corresponding nodes in ndim space. But this doesnt seem like a good way of doing it. Thanks for your help Shobi

aaalgo commented 6 years ago

It takes some code to expose the internal graph structure in python. I'm too busy to do that now. I've exposed a save_text method in python, which will write the graph structure in a text format. You can search FORMAT_TEXT in kgraph.cpp to see how the file is written. I hope that helps.