K-means takes an iterative approach to minimize the distance from points to a given centroid. The centroids begin at random points on the plot and those points closest to each centroid are grouped, and the new centroid computed. This is repeated until there are no changes in the clusters.
-James Cotter