Thank you very much for a very nice and clear implementation.
I wanted to confirm that the optimal number of clusters is the one that has the smallest alignment cost.
Moreover, is it sufficient to stop the iteration over the number of clusters if the cost(i) > cost(i-1) and use (i-1) as the best number of clusters?
Best regards