コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: ppaula/PageRank
        private void GenerateConnections(int num_v, int num_e)
        {
            StackPanelWithConnections.Children.Clear();

            adjacencyMatrix = new AdjacencyMatrix(num_v);
            adjacencyMatrix.Display(StackPanelForDisplayingAdjacencyMatrix, MyCanvas, StackPanelForDisplayingIncidenceMatrix, StackPanelForDisplayingAdjacencylist);


            TextBlock tmpBlock = new TextBlock();

            tmpBlock.Text = "Uzupełnij połączenia:";
            tmpBlock.VerticalAlignment = VerticalAlignment.Center;
            tmpBlock.Margin            = new Thickness(10, 20, 0, 20);
            StackPanelWithConnections.Children.Add(tmpBlock);

            int j = 0;

            ListOfLeftComboBoxes  = new List <ComboBox>();
            ListOfRightComboBoxes = new List <ComboBox>();

            for (int i = 0; i < num_e; i++)
            {
                StackPanel stackPanelForConn = new StackPanel();
                stackPanelForConn.Orientation = Orientation.Horizontal;
                stackPanelForConn.Margin      = new Thickness(20, 0, 0, 0);

                TextBlock fromInfo = new TextBlock();
                fromInfo.Text = "Połączenie od: ";

                TextBlock toInfo = new TextBlock();
                toInfo.Text = " do: ";

                ComboBox fromComboBox = new ComboBox();
                SetComboBox(num_v, fromComboBox);
                fromComboBox.Tag = j;
                ListOfRightComboBoxes.Add(fromComboBox);
                fromComboBox.SelectionChanged += FromComboBox_SelectionChanged;
                fromComboBox.DropDownOpened   += FromComboBox_DropDownOpened;

                ComboBox toComboBox = new ComboBox();
                SetComboBox(num_v, toComboBox);
                toComboBox.Tag       = j + 1;
                toComboBox.IsEnabled = false;
                ListOfLeftComboBoxes.Add(toComboBox);
                toComboBox.SelectionChanged += ToComboBox_SelectionChanged;


                stackPanelForConn.Children.Add(fromInfo);
                stackPanelForConn.Children.Add(fromComboBox);
                stackPanelForConn.Children.Add(toInfo);
                stackPanelForConn.Children.Add(toComboBox);

                StackPanelWithConnections.Children.Add(stackPanelForConn);

                j += 2;
            }
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: ppaula/PageRank
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (Probability_Of_Edge_Occurence.Text != "")
            {
                Probability_Of_Edge_Occurence.Background = Brushes.White;

                //StackPanelWithConnections.Children.Clear();

                Random r = new Random();
                int    v = Int32.Parse(Number_Of_Vertex.Text);

                adjacencyMatrix = new AdjacencyMatrix(v);

                for (int i = 0; i < v; i++)
                {
                    for (int j = 0; j < v; j++)
                    {
                        int probability = r.Next(0, 100);

                        if (probability > Int32.Parse(Probability_Of_Edge_Occurence.Text))
                        {
                            adjacencyMatrix.AdjacencyArray[i, j] = 0;
                        }
                        else
                        {
                            adjacencyMatrix.AdjacencyArray[i, j] = 1;
                        }
                        adjacencyMatrix.AdjacencyArray[i, i] = 0;
                    }
                }

                adjacencyMatrix.Display(StackPanelForDisplayingAdjacencyMatrix, MyCanvas, StackPanelForDisplayingIncidenceMatrix, StackPanelForDisplayingAdjacencylist);
            }
            else
            {
                Probability_Of_Edge_Occurence.Background = Brushes.OrangeRed;
            }
        }