I have a list of solution clusters in the following format:
Input:
test = []
# solutions, centroid
test.append([[3,5],4])
test.append([[2,8],5])
test.append([[1,3],2])
test.append([[5,9],7])
Out: [[[3, 5], 4], [[2, 8], 5], [[1, 3], 2], [[5, 9], 7]]
How would I return the union of the 2 clusters with the smallest centroid distance out of all clusters?
Goal Output: [[2,8,3,5],4.5]
The order of the solutions in the union cluster is not relevant.
I have spent a considerable amount of time trying to come up with a solution with multiple loops to no avail.