I have dataset of 1000 points on a plane. I represented all the possible pairs of points in P and calculated the distances of all possible pairs.What I have to do is: For a given n, calculate all the n-th nearest points for all points p in P.
What I did before:
P_pairs = [((33, 9), (34, 13)), ((33, 9), (62, 119)), ((33, 9), (33, 7)), ((33, 9), (48, 123)), ...]listofdistances = [{'((33, 9), (34, 13))': 4.123105625617661}, {'((33, 9), (62, 119))': 113.75851616472501}, {'((33, 9), (33, 7))': 2.0}, ...]
In this context, I am stuck in sorting listofdistances
such that for every point, there are the minimum n distances as values left.
Maybe I have to calculate the n-th nearest points directly, instead of calculating all the distances of the points. But I don't exactly know how.