コード例 #1
0
ファイル: MM_Math.cs プロジェクト: avmaxim/K-means-Clustering
        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);
        }