Algorithms for Clustering, Partitioning, and Planning