functional simple k-means clustering
handles empty clusters