CanvasCommon.DensityClusteringModel.FindCentroids C# (CSharp) Метод

FindCentroids() публичный Метод

Estimate Centroids value as Centroids(i) = distance of the closes data point of higher density (min(d[i,j] for all j:=Rho(j)>Rho(i)))
public FindCentroids ( ) : void
Результат void
        public void FindCentroids()
        {
            int segmentsLength = this.Segments.Count;
            this.Centroids = new List<double>(segmentsLength);
            for (int iCentroids = 0; iCentroids < segmentsLength; iCentroids++)
                this.Centroids.Add(0);
            List<double> maximum = new List<double>(segmentsLength);
            for (int imaximum = 0; imaximum < segmentsLength; imaximum++)
                maximum.Add(0);
            int i = 0;
            for (int col = 0; col < segmentsLength; col++)
            {
                for (int row = col + 1; row < segmentsLength; row++)
                {
                    if (!this.Distance[i].HasValue)
                    {
                        i++;
                        continue;
                    }
                    double newValue = (double) this.Distance[i];
                    double rhoRow = this.Rho[row];
                    double rhoCol = this.Rho[col];

                    if (rhoRow > rhoCol)
                    {
                        double CentroidsCol = this.Centroids[col];
                        if (newValue < CentroidsCol || CentroidsCol == 0)
                        {
                            this.Centroids[col] = newValue;
                        }
                    }
                    else if (newValue > maximum[col])
                    {
                        maximum[col] = newValue;
                    }

                    if (rhoCol > rhoRow)
                    {
                        double CentroidsRow = this.Centroids[row];
                        if (newValue < CentroidsRow || CentroidsRow == 0)
                        {
                            this.Centroids[row] = newValue;
                        }
                    }
                    else if (newValue > maximum[row])
                    {
                        maximum[row] = newValue;
                    }
                    i++;
                }
            }
            for (int j = 0; j < segmentsLength; j++)
            {
                if (this.Centroids[j] == 0)
                {
                    this.Centroids[j] = maximum[j];
                }
            }
        }