static void Main(string[] args) { p = new Graf_random_gen(w1, k1); Console.WriteLine("Mam Testy!!"); string[] temp = new string[w1]; for (int i = 0; i < w1; i++) { temp[i] = p.Nastepny_wierzchołek(); } Graf1 g1 = new Graf1(temp); Graf2 g2 = new Graf2(); Console.WriteLine("Graf 1 ma wierzchołki!!"); p.Reset_wie(); for (int i = 0; i < w1; i++) { string h = p.Nastepny_wierzchołek(); g2.Dodaj_wierzchołek(h); } Console.WriteLine("Graf 2 ma wierzchołki!!"); for (int i = 0; i < k1; i++) { triple h = p.Nastepna_krawedz(); g1.Dodaj_krawędź_z_wagą(h.get_a(), h.get_b(), h.get_c()); g1.Dodaj_krawędź_z_wagą(h.get_b(), h.get_a(), h.get_c()); g2.Dodaj_krawędź_z_wagą(h.get_a(), h.get_b(), h.get_c()); g2.Dodaj_krawędź_z_wagą(h.get_b(), h.get_a(), h.get_c()); } Console.WriteLine("Oba grafy gotowe!!"); Stopwatch k = new Stopwatch(); int a, b; Random rand = new Random(); a = rand.Next(w1); b = rand.Next(w1); //Rozpoczęcie testu 1 Console.WriteLine("Pierwszy test:"); k.Start(); Dijkstra(temp[a], temp[b], g1); k.Stop(); Console.WriteLine("Czas potrzebny pierwszej implementacji:" + k.Elapsed); //Zakończenie testu 1 k.Reset(); //Rozpoczącie testu 2 Console.WriteLine("Drugi test:"); k.Start(); Dijkstra(temp[a], temp[b], g2); k.Stop(); Console.WriteLine("Czas potrzebny drugiej implementacji:" + k.Elapsed); //Zakończenie testu 2 }
private void chart2_MouseMove(object sender, MouseEventArgs e) { try { #region VerificaX var pos = e.Location; if (prevPosition.HasValue && pos == prevPosition.Value) { return; } tooltip.RemoveAll(); prevPosition = pos; var results = Graf2.HitTest(pos.X, pos.Y, false, ChartElementType.PlottingArea); foreach (var result in results) { if (result.ChartElementType == ChartElementType.PlottingArea) { var xVal = result.ChartArea.AxisX.PixelPositionToValue(pos.X); var yVal = result.ChartArea.AxisY.PixelPositionToValue(pos.Y); //Atribui à variável o número da coluna que o mouse está sobre. pontoAtual = Convert.ToInt32(Math.Round(xVal)); } } #endregion #region Pinta Ponto selecionado // Call HitTest HitTestResult resultado = Graf2.HitTest(e.X, e.Y); // Reset Data Point Attributes foreach (DataPoint point in Graf2.Series[0].Points) { point.BackSecondaryColor = Color.Black; point.BackHatchStyle = ChartHatchStyle.None; point.BorderWidth = 1; } foreach (DataPoint point in Graf2.Series[1].Points) { point.BackSecondaryColor = Color.Black; point.BackHatchStyle = ChartHatchStyle.None; point.BorderWidth = 1; } // If the mouse if over a data point if (resultado.ChartElementType == ChartElementType.DataPoint) { // Find selected data point DataPoint point = Graf2.Series[0].Points[resultado.PointIndex]; DataPoint point1 = Graf2.Series[1].Points[resultado.PointIndex]; // Change the appearance of the data point point.BackSecondaryColor = Color.White; point.BackHatchStyle = ChartHatchStyle.Percent25; point.BorderWidth = 2; point1.BackSecondaryColor = Color.White; point1.BackHatchStyle = ChartHatchStyle.Percent25; point1.BorderWidth = 2; // label3.Text = graficoComparativo1.Series[0].Points[resultado.PointIndex].ToString(); } else { // Set default cursor this.Cursor = Cursors.Default; //Se o mouse não está sobre nehuma coluna, atribui à variável o valor 0. pontoAtual = 0; } #endregion } catch { } }