Esempio n. 1
0
        /// <summary>
        /// Updates the clustering of any points
        /// </summary>
        private void UpdateClusters()
        {
            //Get K from textbox
            int k;

            try
            {
                k = int.Parse(kTextBox.Text);
            }
            catch
            {
                return;
            }

            //Less points than clusters - not possible
            if (Points.Count() < k)
            {
                return;
            }

            if (!FirstCluster)
            {
                //KCluster algorithm
                ClusterAlgo  = new KCluster(Points);
                Clusters     = ClusterAlgo.Solve(k);
                FirstCluster = true;
            }
            else
            {
                //Add the point to the nearest cluster
                Clusters = ClusterAlgo.ClusterNewPoint(Points.Last());
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Updates the clustering of any points
        /// </summary>
        private void UpdateClusters()
        {
            //Get K from textbox
            int k;
            try
            {
                k = int.Parse(kTextBox.Text);
            }
            catch
            {
                return;
            }

            //Less points than clusters - not possible
            if (Points.Count() < k)
                return;

            if (!FirstCluster)
            {
                //KCluster algorithm
                ClusterAlgo = new KCluster(Points);
                Clusters = ClusterAlgo.Solve(k);
                FirstCluster = true;
            }
            else
            {
                //Add the point to the nearest cluster
                Clusters = ClusterAlgo.ClusterNewPoint(Points.Last());
            }
        }