This website visualizes the two steps of k-means clustering :
- Assign : Assigning every point in the data to the cluster whose centroid is nearest to it.
Optimize : Recalculating each centroid’s location as the mean (center) of all the points assigned to its cluster.
This process is then iterated until the centroids stop moving, or equivalently until the points stop switching clusters.
You can take a look at it here.