public ClusterPoint(ClusterPoint p, int clusterNumber) { this.X = p.X; this.Y = p.Y; this.XT = p.XT; this.YT = p.YT; this.ClusterNumber = clusterNumber; }
private void InitializeCentroids() { Random rnd = new Random(); clusterData.Centroids = new List <ClusterPoint>(); for (int i = 0; i < this.K; i++) { ClusterPoint p = clusterData.Points[rnd.Next(clusterData.Points.Count)]; clusterData.Centroids.Add(new ClusterPoint(p, i)); } }
public void Add(ClusterPoint point) { Points.Add(point); }
public static double Chebyshev(ClusterPoint p1, ClusterPoint p2) => Max(Abs(p1.XT - p2.XT), Abs(p1.YT - p2.YT));
public static double Manhattan(ClusterPoint p1, ClusterPoint p2) => Abs(p1.XT - p2.XT) + Abs(p1.YT - p2.YT);
public static double Euclidean(ClusterPoint p1, ClusterPoint p2) => Sqrt(SquaredEuclidean(p1, p2));
public static double SquaredEuclidean(ClusterPoint p1, ClusterPoint p2) => (p1.XT - p2.XT) * (p1.XT - p2.XT) + (p1.YT - p2.YT) * (p1.YT - p2.YT);