Ejemplo n.º 1
0
        public void Display(StackPanel StackPanelForDisplayingIncidenceMatrix, StackPanel StackPanelForDisplayingAdjacencylist)
        {
            StackPanelForDisplayingIncidenceMatrix.Children.Clear();

            string myString = "";

            for (int i = 0; i < IncidenceArray.GetLength(0); i++)
            {
                for (int j = 0; j < IncidenceArray.GetLength(1); j++)
                {
                    if (IncidenceArray[i, j] < 0)
                    {
                        myString += IncidenceArray[i, j].ToString() + "  ";
                    }
                    else
                    {
                        myString += " " + IncidenceArray[i, j].ToString() + "  ";
                    }
                }
                myString += "\n";
            }

            TextBlock myBlock = new TextBlock();

            myBlock.Text       = myString;
            myBlock.FontSize   = 16;
            myBlock.FontFamily = new FontFamily("Lucida Console");
            StackPanelForDisplayingIncidenceMatrix.Children.Add(myBlock);

            // Nowa lista sąsiedztwa
            adjacencyList = new AdjacencyList(this);
            adjacencyList.Display(StackPanelForDisplayingAdjacencylist);
        }
Ejemplo n.º 2
0
        private void AdjacencyList_to_AdjacencyMatrix_Click(object sender, RoutedEventArgs e)
        {
            if (adjacencyMatrix != null)
            {
                IncidenceMatrix tmpIncendenceMatrix      = new IncidenceMatrix(adjacencyMatrix);
                AdjacencyList   tmpAdjacencyList         = new AdjacencyList(tmpIncendenceMatrix);
                AdjacencyMatrix convertedAdjacencyMatrix = new AdjacencyMatrix(tmpAdjacencyList);

                convertedAdjacencyMatrix.Display(StackPanelForDisplayingAdjacencyMatrix, MyCanvas, StackPanelForDisplayingIncidenceMatrix, StackPanelForDisplayingAdjacencylist);
            }
        }
Ejemplo n.º 3
0
        public AdjacencyMatrix(AdjacencyList adjacencyList)
        {
            var num_of_v = adjacencyList.ListOfLists.Count;

            AdjacencyArray = new int[num_of_v, num_of_v];

            for (int i = 0; i < num_of_v; i++)
            {
                for (int j = 0; j < num_of_v; j++)
                {
                    AdjacencyArray[i, j] = 0;
                }
            }


            for (int i = 0; i < num_of_v; i++)
            {
                for (int j = 0; j < adjacencyList.ListOfLists[i].Count; j++)
                {
                    AdjacencyArray[i, adjacencyList.ListOfLists[i][j] - 1] = 1;
                    AdjacencyArray[adjacencyList.ListOfLists[i][j] - 1, i] = 1;
                }
            }
        }