Clustering: Algorithm, Optimization And Inference