Пример #1
0
        private void Form3_Load(object sender, EventArgs e)
        {
            int n = matrixIncident.GetLength(0);

            for (int i = 0; i < n; i++)
            {
                string head = "x" + Convert.ToString(i + 1);
                dataGridView1.Columns.Add(head, head);
                dataGridView1.Columns[i].Width = 30;
                dataGridView2.Columns.Add(head, head);
                dataGridView2.Columns[i].Width = 30;
            }
            if (n > 0)
            {
                dataGridView1.Rows.Add(n);
                dataGridView2.Rows.Add(n);
            }

            for (int i = 0; i < n; i++)
            {
                string head = "x" + Convert.ToString(i + 1);
                dataGridView1.Rows[i].HeaderCell.Value = head;
                dataGridView2.Rows[i].HeaderCell.Value = head;
            }
            Process  p = Process.GetCurrentProcess();
            TimeSpan ts;

            ts = p.TotalProcessorTime;
            for (int g = 0; g < count; g++)
            {
                for (int i = 0; i < n; i++)
                {
                    Dijkstra algo = new Dijkstra(ref matrixIncident, i);
                    int[]    len  = algo.Run2();
                    for (int j = 0; j < n; j++)
                    {
                        dataGridView1[j, i].Value = len[j];
                    }
                }
            }
            ts           = p.TotalProcessorTime - ts;
            label3.Text += (ts.Seconds.ToString() + " с " + ts.Milliseconds + " мс");


            ts = p.TotalProcessorTime;
            for (int g = 0; g < count; g++)
            {
                Floyd f1 = new Floyd(ref matrixIncident, 0);
                int[,] result = f1.RunFull();
                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        dataGridView2[j, i].Value = result[i, j];
                    }
                }
            }
            ts           = p.TotalProcessorTime - ts;
            label4.Text += (ts.Seconds.ToString() + " с " + ts.Milliseconds + " мс");
        }
Пример #2
0
 /// <summary>
 /// Запуск алгоритма Флойда
 /// </summary>
 /// <param name="e"></param>
 private void RunAlgoF(MouseEventArgs e)
 {
     CheckTwoNodes(e);
     if (checkedNodes.Count == 2)
     {
         int s = int.Parse(checkedNodes[0].Name.Replace("x", "")) - 1;
         int t = int.Parse(checkedNodes[1].Name.Replace("x", "")) - 1;
         ClearSelected();
         Floyd algo = new Floyd(ref matrixIncident, s, t);
         RunAlgo(e, algo);
     }
 }