예제 #1
0
        public void ReLayoutGraph()
        {
            //dane potrzebne w metodach obsługujących macierz
            MatrixMethod.NumberOfVertices = _numberOfVertices;
            MatrixMethod.ProbabilityValue = _probabilityValue;

            Graph             = new Graph(true);              //nowy graf
            _matrix           = MatrixMethod.FillTheMatrix(); //macierz incydencji
            _existingVertices = new List <Vertex>();          //lista przechowująca wierzchołki

            //wygenerowanie odpowiedniej ilości wierzchołków
            for (int i = 0; i < _numberOfVertices; i++)
            {
                _existingVertices.Add(new Vertex((i + 1).ToString(), i));
                Graph.AddVertex(_existingVertices[i]);
            }

            //generowanie krawędzi na podstawie macierzy
            EdgeMethod.GenerateEdges(_matrix, _existingVertices, Graph);

            //suma jest zapisana w ostatniej kolumnie macierzy oraz we właściwości obiektu vertex(VertexDegree)<=potrzebne w naprawie
            VertexMethod.CalculateTheSum(_matrix, _existingVertices);

            //zapisanie wierzołków sąsiadujących ze sobą(potrzebne w naprawie)
            VertexMethod.SetVertexNeighbors(_matrix, _existingVertices);

            UndirectedGraph = new UndirectedBidirectionalGraph <Vertex, Edge>(Graph);//coś jak canvas


            RefreshMatrixUi();//odświeżenie UI
        }
        private void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            //Example graph from AI
            GraphGenerationMethods graphGenerator = new GraphGenerationMethods(_parameters);

            graphGenerator.GenerateTriangulationOfGraph();

            //Refresh pareto front
            var cutsSum     = EdgeMethod.GetCutsWeightsSum(_parameters.GeneratedBasicGraph, _parameters.Population);
            var cutsCount   = EdgeMethod.GetCutsCount(_parameters.GeneratedBasicGraph, _parameters.Population);
            var paretoArray = cutsCount.
                              Zip(cutsSum, (first, second) => (first, second)).
                              Select(x => new double[] { x.first, x.second }).ToList();

            _parameters.RewriteThePoints(paretoArray);
            _parameters.MainWindow.ParetoChart.EditSeriesCollection(_parameters.ListOfPoints);

            //aktualizacja macierzy incydencji
            MatrixMethod matrixMethod = new MatrixMethod(_parameters);

            _parameters.incidenceMatrix = matrixMethod.FillTheSecondHalfOfTheMatrix(_parameters.incidenceMatrix);

            _parameters.GeneratedBasicGraph = EdgeMethod.GenerateEdges(_parameters.incidenceMatrix, _parameters.verticesBasicGeneratedGraph, _parameters.GeneratedBasicGraph);

            //aktualizacja wyświetlanej macierzy incydencji i wag (frontend)
            VertexMethod.CalculateTheSum(_parameters.incidenceMatrix, _parameters.verticesTriangulationOfGraph);
            VertexMethod.SetVertexNeighbors(_parameters.incidenceMatrix, _parameters.verticesTriangulationOfGraph);

            _parameters.MainWindow.OverallFluctuationChart.EditASeries(
                _parameters.FitnessArray.Average(),
                _parameters.IterationNumber);

            _parameters.MainWindow.SecondChart.EditBSeries(
                _parameters.FitnessArray.Min(),
                _parameters.IterationNumber);

            var minimumFitnessGraphIndex = _parameters.FitnessArray.ToList().IndexOf(_parameters.FitnessArray.Min());

            //var minimumFitnessGraphIndex = 0;
            _parameters.CountedExtremum = $"({cutsCount[minimumFitnessGraphIndex]}; {cutsSum[minimumFitnessGraphIndex]})";

            _parameters.MainWindow.ProgressBar.Value = _parameters.IterationNumber;

            _parameters.CurrentGroupsVertices = GraphGenerationMethods.GetGroupsVertices(
                _parameters.GeneratedBasicGraph,
                _parameters.Population,
                minimumFitnessGraphIndex);
            string groupsVerticesString = "";

            if (_parameters.CurrentGroupsVertices.ContainsValue(0))
            {
                groupsVerticesString += "Warning: group 0 detected. ";
            }
            _parameters.CurrentGroupsVertices.OrderBy(x => x.Key.Index).ToList().ForEach(x => groupsVerticesString += $"V: {x.Key.Index + 1}, G: {x.Value}; ");
            _parameters.MainWindow.GroupList.Content = groupsVerticesString;

            matrixMethod.RefreshMatrixUi(_parameters.TriangulationOfGraph);

            _parameters.MainWindow.ResetZoomControl(_parameters.MainWindow.TriangulationGraphZoomControl);
        }
예제 #3
0
        private void worker_ProgressChanged(object sender, System.ComponentModel.ProgressChangedEventArgs e)
        {
            ////aktualizacja macierzy

            _matrix = MatrixMethod.FillTheSecondHalfOfTheMatrix(_matrix);
            //EdgeMethod.RemoveAllGraphEdges(Graph);

            Graph = EdgeMethod.GenerateEdges(_matrix, _existingVertices, Graph);

            // int edgeCounter = Graph.Edges.Count();
            ////aktualizacja tabeli
            VertexMethod.CalculateTheSum(_matrix, _existingVertices);
            VertexMethod.SetVertexNeighbors(_matrix, _existingVertices);

            RefreshMatrixUi();
        }