Example #1
0
 /// <summary>
 /// Redefining the cluster centroid according to the center of gravity
 /// </summary>
 /// <param name="metricDistance">Method of calculating distance</param>
 public void SetCentroidLikeGravityCenter(IMetricDistance metricDistance)
 {
     if (Data.Count != 0)
     {
         if (metricDistance.GetValueOfDistance(GetGravityCenter(), ClustersCendroid) > 0.01)
         {
             ClustersCendroid = new Centroid(GetGravityCenter().X, GetGravityCenter().Y);
             ChangeCentroid?.Invoke(this, null);
         }
     }
     else
     {
         ClustersCendroid = ClustersCendroid;
     }
 }
Example #2
0
 /// <summary>
 /// Constructor of class Cluster
 /// </summary>
 /// <param name="id">Id</param>
 /// <param name="data">Clusters data</param>
 /// <param name="cendroid">Object of class cendroid for cluster</param>
 public Cluster(int id, List <ClusteredData> data, Centroid cendroid)
 {
     Id               = id;
     Data             = data;
     ClustersCendroid = cendroid;
 }
Example #3
0
 /// <summary>
 /// Constructor of class Cluster
 /// </summary>
 /// <param name="id">Id</param>
 /// <param name="cendroid">Object of class cendroid for cluster</param>
 public Cluster(int id, Centroid cendroid)
 {
     Id               = id;
     Data             = new List <ClusteredData>();
     ClustersCendroid = cendroid;
 }
Example #4
0
        /// <summary>
        /// Calculating the center of gravity for a cluster
        /// </summary>
        /// <returns>Object of class cendroid for cluster</returns>
        public Centroid GetGravityCenter()
        {
            Centroid newCentroid = new Centroid(Data.Average(a => a.X), Data.Average(a => a.Y));

            return(newCentroid);
        }