Centroid computation and Lloyd algorithm