implementation of spectral clustering (k means)