Distributed k-Means and k-Median Clustering on General Topologies