k-means algorithm with (optional) instance weights.