Make list of group with nearby points in a cluster


I have a cluster with points (see below) and I want to generate a list with groups of 3 points that are nearest to eachother (so that you could build an equilateral triangle). I tried to use “KDTree” and “closest points” which did not result in the wanted outcome. When using KDTree and then generating triangles with the points in all groups, it looks like not all combinations of points are used (see second picture below).

I then want to make triangles same as in the second picture but one point can only be used once. Here, I have to somehow delete all groups I generated that have a number in it which is already used in another group.

Does someone of you have an idea where to begin with my problem or has done something similar already?

All help is appreciated. Thanks a lot!



Moved to Grasshopper category