Changed code to use k-means clustering when clustering by similarity