// Start algorytmu najkrótszej ścieżki. private void buttonShortestPathRun_Click(object sender, EventArgs e) { if (graph != null) { if (radioButtonShortestPathDijkstra.Checked) { if (!negative) { shortestPathDijkstra = new ShortestPathDijkstra(graph, radioButtonModeList.Checked, inputArray[2]); shortestPathDijkstraClock = new Clock(graph, shortestPathDijkstra); for (int i = 0; i < repeat; i++) { shortestPathDijkstraClock.Start(); shortestPathDijkstra = new ShortestPathDijkstra(graph, radioButtonModeList.Checked, inputArray[2]); shortestPathDijkstra.Work(); shortestPathDijkstraClock.Stop(); } shortestPathDijkstraClock.End(); textBoxShortestPathTime.Text = shortestPathDijkstraClock.Average().ToString(); } else { MessageBox.Show("Krawędź ujemna! Dijkstra nie może wystartować!", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { shortestPathBellmanFord = new ShortestPathBellmanFord(graph, radioButtonModeList.Checked, inputArray[2]); shortestPathBellmanFordClock = new Clock(graph, shortestPathBellmanFord); for (int i = 0; i < repeat; i++) { shortestPathBellmanFordClock.Start(); shortestPathBellmanFord = new ShortestPathBellmanFord(graph, radioButtonModeList.Checked, inputArray[2]); shortestPathBellmanFord.Work(); shortestPathBellmanFordClock.Stop(); } shortestPathBellmanFordClock.End(); textBoxShortestPathTime.Text = shortestPathBellmanFordClock.Average().ToString(); } } else { MessageBox.Show("Graf nie został stworzony!", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// Start algorytmu drzewa rozpinającego. private void buttonSpanningTreeRun_Click(object sender, EventArgs e) { if (graph != null) { if (radioButtonSpanningTreeKruskal.Checked) { spanningTreeKruskal = new SpanningTreeKruskal(graph, radioButtonModeList.Checked); spanningTreeKruskalClock = new Clock(graph, spanningTreeKruskal); for (int i = 0; i < repeat; i++) { spanningTreeKruskalClock.Start(); spanningTreeKruskal = new SpanningTreeKruskal(graph, radioButtonModeList.Checked); spanningTreeKruskal.Work(); spanningTreeKruskalClock.Stop(); } spanningTreeKruskalClock.End(); textBoxSpanningTreeTime.Text = spanningTreeKruskalClock.Average().ToString(); } else { spanningTreePrim = new SpanningTreePrim(graph, radioButtonModeList.Checked, 0); spanningTreePrimClock = new Clock(graph, spanningTreePrim); for (int i = 0; i < repeat; i++) { spanningTreePrimClock.Start(); spanningTreePrim = new SpanningTreePrim(graph, radioButtonModeList.Checked, 0); spanningTreePrim.Work(); spanningTreePrimClock.Stop(); } spanningTreePrimClock.End(); textBoxSpanningTreeTime.Text = spanningTreePrimClock.Average().ToString(); } } else { MessageBox.Show("Graf nie został stworzony!", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error); } }