Clustering algorithm for carpooling