Distributed k-means and k-median Clustering on General Topologies