public static KeyValuePair<int, int> MaxAndArgMaxComboFromSquaredEuclideanDistances(CPoint centroid, Cluster cluster, List<CPoint> allPoints) { int argmax = -1; int max = -1; var clusterPoints = cluster.GetPointAsList(); for (int i = 0; i < cluster.GetPointsCount(); i++) { var distance = SquaredEuclideanDistance(centroid, clusterPoints[i]); if (distance > max) { max = distance; argmax = allPoints.IndexOf(clusterPoints[i]); } } return new KeyValuePair<int, int>(argmax, max); }