Пример #1
0
        private void GenerateGraph(object sender, RoutedEventArgs args)
        {
            if (sender == ErdosRenyiMenuItem)
            {
                var w = new ErdosGenerator();
                try
                {
                    w.ShowDialog();
                    Graph.Clear();
                    Graph.Set(GraphGenerator.CreateDirectional(w.DataContext as GraphMatrix));
                    Graph.OnChange();
                }
                catch (Exception e)
                {
                    MessageBoxResult result = MessageBox.Show("Coś poszło nie tak"
                                                              + System.Environment.NewLine
                                                              + e.Message
                                                              );
                }
            }
            else if (sender == SecondGeneratorMenuItem)
            {
                var w = new SecondGenerator();
                try
                {
                    w.ShowDialog();
                    Graph.Clear();
                    Graph.Set(GraphGenerator.CreateDirectional(w.DataContext as GraphMatrix));
                    Graph.OnChange();
                }
                catch (Exception e)
                {
                    MessageBoxResult result = MessageBox.Show("Coś poszło nie tak"
                                                              + System.Environment.NewLine
                                                              + e.Message
                                                              );
                }
            }

            Graph.Set(GraphGenerator.CreateRandomDirectedWeights(Graph));
            Graph.OnChange();
            Renderer.Displayer = new DirectedCircleDisplayer();
        }
Пример #2
0
        private void GenerateGraph(object sender, RoutedEventArgs args)
        {
            Stopwatch watch = null;
            //long before = 0;
            long after = 0;

            if (sender == ErdosRenyiMenuItem)
            {
                var w = new ErdosGenerator();
                try
                {
                    w.ShowDialog();
                    watch = Stopwatch.StartNew();
                    Graph.Clear();
                    Graph.Set(w.DataContext as GraphMatrix);
                    //before = watch.ElapsedMilliseconds;
                    Graph.OnChange();
                    watch.Stop();
                    after = watch.ElapsedMilliseconds;
                }
                catch (Exception e)
                {
                    MessageBoxResult result = MessageBox.Show("Coś poszło nie tak"
                                                              + System.Environment.NewLine
                                                              + e.Message
                                                              );
                }
            }
            else if (sender == SecondGeneratorMenuItem)
            {
                var w = new SecondGenerator();
                try
                {
                    w.ShowDialog();
                    watch = Stopwatch.StartNew();
                    Graph.Clear();
                    Graph.Set(w.DataContext as GraphMatrix);
                    //before = watch.ElapsedMilliseconds;
                    Graph.OnChange();
                    watch.Stop();
                    after = watch.ElapsedMilliseconds;
                }
                catch (Exception e)
                {
                    MessageBoxResult result = MessageBox.Show("Coś poszło nie tak"
                                                              + System.Environment.NewLine
                                                              + e.Message
                                                              );
                }
            }

            if (watch != null)
            {
                //MessageBox.Show(
                //    "Before = " + (double)(before / 1000.0) +
                //    System.Environment.NewLine +
                //    "After = " + (double)(after / 1000.0));
            }

            GraphRenderer.Displayer = new CircleDisplayer();
        }