I’m currently trying to figure out a method to create an efficient grouping of 2D points. The scenario is as follows:

I have 96 points which I need to cluster into groups of 24 groups of 4, with the efficiency based on minimizing the distance between points within their respective groups. I have looked through numerous posts that takes k-means clustering as an approach for group points efficiently into a set number of groups, however the number of points in the resulting groups is never strictly defined in those approaches.

I don’t currently see a way to approach this problem linearly and I’m not sure its possible. I’ve attached my attempt at a basic approach to grouping the points into sets of 4 but since it is a linear approach it does not provide an efficient grouping for the points as a whole.

Does anyone have some insight on this problem?

Point_Groups_4.gh (12.6 KB)