public void RandomSecondGeneratorTest(int n) { SecondGenerator generator = new SecondGenerator(); var result = generator.GenerateArray(n); Assert.IsTrue(Math.Abs(result.Sum() - 1) < 0.000001); }
public void GeneratorExeptionTest(int n) { SecondGenerator secondGenerator = new SecondGenerator(); FirstGenerator firstGenerator = new FirstGenerator(); Assert.Throws <ArgumentException>(() => firstGenerator.GenerateArray(n)); Assert.Throws <ArgumentException>(() => secondGenerator.GenerateArray(n)); }
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(); }
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(); }