Esempio n. 1
0
 public static void FindCentroid(Kmean graph)
 {
     foreach (Claster claster in graph.clasters)
     {
         CPoint result  = new CPoint(0, 0);
         int    divider = 0;
         foreach (var edge in claster.edges)
         {
             result += edge.Item1;
             divider++;
         }
         if (divider != 0)
         {
             result /= divider;
         }
         claster.Centroid = result;
     }
 }
Esempio n. 2
0
        private void Form1_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                PictureBox bluePoint = new PictureBox();
                PictureSettings(e, bluePoint, "img/BluePoint.png");
                Controls.Add(bluePoint);

                CPoint point = new CPoint(e.X, e.Y);
                graph.AddPoint(point);
            }
            else if (e.Button == MouseButtons.Right)
            {
                PictureBox redPoint = new PictureBox();
                PictureSettings(e, redPoint, "img/RedPoint.png");
                Controls.Add(redPoint);

                Claster claster = new Claster(e.X, e.Y);
                graph.AddClaster(claster);
            }
        }
Esempio n. 3
0
 public void AddPoint(CPoint p)
 {
     points.Add(p);
 }