Finding Neighborhood Selection using Python


This is my code that finds the number of neighboring points based on the indexes you give it. In this red box, the first index in each sublist is the point we want to find its neighbor, and the second index is the number of neighbors we want, but the problem is that it chooses duplicate points between each sublist.
nearest point.gh (11.4 KB)

@Mahdiyar

You need to keep track of which points have already been allocated. A set or dictionary gives o(1) look ups for this. Or remove the points from their original list when they are allocated to a sublist, so they can’t be allocated again.

It doesn’t work because I call index from the original list to find neighbors