The algorithm works by randomly selecting k centroids. Then all items are assigned to the cluster whose centroid is the closest to them. The new cluster centroid
needs to be updated to account for the items who have been added or removed from
the cluster and the membership of the items to the cluster updated. This operation
continues until there are no further items that change their cluster membership. Most
of the convergence to the final partition takes place during the first iterations of the
algorithm, and therefore, the stopping condition is often changed to “until relatively
few points change clusters” in order to improve efficiency.