Implemented Kmedoid algorithm.