Implemented KNN graph construction, but has known segmentation fault