public JarvisPatrick(List <DataPoint> dataPoints, ProcessingData data) : base(dataPoints, data)
 {
     foreach (DataPoint point in Points)
     {
         point.NearestNeighbors = new List <DataPoint>();
         foreach (DataPoint neighborPoint in Points)
         {
             if (point.Index != neighborPoint.Index)
             {
                 if ((point.NearestNeighbors.Count < ProcessingData.NeighborsToExamine))
                 {
                     point.NearestNeighbors.Add(neighborPoint);
                     SortNeighbors(point);
                 }
                 else
                 {
                     if ((Distance(neighborPoint, point)) < (Distance(point, point.NearestNeighbors[point.NearestNeighbors.Count - 1])))
                     {
                         point.NearestNeighbors[point.NearestNeighbors.Count - 1] = neighborPoint;
                         SortNeighbors(point);
                     }
                 }
             }
         }
     }
 }
示例#2
0
 public Hierarchical(List <DataPoint> dataPoints, ProcessingData data) : base(dataPoints, data)
 {
     clusterHistory.Add(new List <Cluster>());
     foreach (DataPoint point in Points)
     {
         clusters.Add(new Cluster());
         clusters[clusters.Count - 1].Points.Add(point);
         clusterHistory[0].Add(new Cluster(clusters[clusters.Count - 1]));
     }
 }
示例#3
0
        public KMeans(List <DataPoint> dataPoints, ProcessingData data) : base(dataPoints, data)
        {
            DataPoint tmp = new DataPoint();

            Thread.Sleep(20);
            Random rand = new Random((int)DateTime.Now.Ticks & 0x0000FFFF);

            for (int i = 0; i < ProcessingData.GroupsQuantity; i++)
            {
                for (int j = 0; j < ProcessingData.dimensionQuantity; j++)
                {
                    tmp.Coordinates.Add((rand.Next(0, 60001)) / (double)100);
                }
                Clusters.Add(new Cluster(new DataPoint(tmp)));
                tmp.Coordinates.Clear();
            }
        }
示例#4
0
        private void StartButton_Click(object sender, RoutedEventArgs e)
        {
            if (_startAlreadyClicked)
            {
                ProcessingData oldProcessingData = main.processingData;
                main = new MainProgramClass(oldProcessingData);
            }

            _startAlreadyClicked = true;

            for (int i = 0; i < 3; i++)
            {
                if (main.processingData.AlgorithmChecklist[i] == true)
                {
                    break;
                }
                if (i == 4)
                {
                    MessageBox.Show("Proszę wybrać algorytm");
                    return;
                }
            }

            if ((RandomDataRadioButton.IsChecked == false) && (FromFileRadioButton.IsChecked == false) && (FromBitmapRadioButton.IsChecked == false))
            {
                MessageBox.Show("Proszę wybrać typ danych wejściowych");
                return;
            }

            if (((FromFileRadioButton.IsChecked == true) || (FromBitmapRadioButton.IsChecked == true)) && (main.processingData.InputFilePath == ""))
            {
                MessageBox.Show("Proszę wybrać plik wejściowy");
                return;
            }

            if (main.processingData.OutputFilePath == "result.txt")
            {
                MessageBox.Show("Nie wybrano pliku. Wyniki zostaną zapisane w domyślnym pliku result.txt");
            }

            if (RandomDataRadioButton.IsChecked == true)
            {
                try
                {
                    main.processingData.PointsQuantity    = int.Parse(QuantityInputTextBox.Text);
                    main.processingData.dimensionQuantity = int.Parse(DimensionTextBox.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("Proszę wpisać liczbę całkowitą.");
                    return;
                }
            }

            if (KmeansCheckbox.IsChecked == true)
            {
                try
                {
                    main.processingData.GroupsQuantity = int.Parse(GroupQuantityTextBox.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("Proszę wpisać liczbę całkowitą.");
                    return;
                }
            }

            if (JarvisPatrickCheckbox.IsChecked == true)
            {
                try
                {
                    main.processingData.RequiredNeighbors  = int.Parse(NeighborsInCommonTextBox.Text);
                    main.processingData.NeighborsToExamine = int.Parse(NeighborsToExamineTextBox.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("Proszę wpisać liczbę całkowitą.");
                    return;
                }
            }


            main.Setup();
        }
示例#5
0
 public AverageLinkageHierarchical(List <DataPoint> dataPoints, ProcessingData data) : base(dataPoints, data)
 {
 }