private void GenerateCriticalPointChart(Chart chart, int N) { int iter = 100; double max = (double)5 / N; double max_portion = max / iter; double[] datax = new double[iter]; double[] datay = new double[iter]; chart.Series.Clear(); chart.Legends.Clear(); chart.Titles.Clear(); chart.ChartAreas.Clear(); for (int i = 0; i < iter; i++) { //RandomGraph g = new RandomGraph(N, (double)i/iter); ErdösRenyiModel g = new ErdösRenyiModel(N, (double)max_portion * i); if ((double)2 * g.getCount() / N > 5) { break; } datay[i] = (double)g.getGCC() / N; datax[i] = (double)2 * g.getCount() / N; } ChartSeries(chart, datax, datay, "<k> = Ng/N", iter, N); ChartAreas(chart, "Ng/N", 5); ChartTitle(chart, ""); }
private void ErdosGenerateButton_Click(object sender, EventArgs e) { int.TryParse(ErdosNumberOfNodesTextBox.Text, out var numberOfNodes); int N = numberOfNodes; double.TryParse(ErdosProbabilityTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture, out var probability); if (radioButton1.Checked) { var model = new ErdösRenyiModel(numberOfNodes, probability); if (visualize) { var graphviz = new GraphvizAlgorithm <int, UndirectedEdge <int> >(model.Graph); string output = graphviz.Generate(new FileDotEngine(), "graph"); ErdosGraphPictureBox.ImageLocation = @"graph.png"; } double avg_k = (double)2 * model.getCount() / numberOfNodes;; double expected_avg_k = probability * (numberOfNodes - 1); label18.Text = string.Format(@"{0}", avg_k); label13.Text = string.Format(@"{0}", expected_avg_k); label15.Text = string.Format(@"{0}", model.getGCC()); // label3.Text = string.Format(@"{0}", Metrics.ClusteringCoefficientMetric.Analyze(model, false)); var degreeDistribuition = model.DegreeDistribuition(); //foreach (var degree in degreeDistribuition) //{ // Console.WriteLine($@"{degree.Key} - {degree.Value}"); //} ErdosDistribuitionDegreeChart.Titles.Add(new Title(RandomGraphStrings.DegreeChartTitle)); GenerateDegreeDistribuitionChart(ErdosDistribuitionDegreeChart, degreeDistribuition); } if (radioButton2.Checked) { GenerateCriticalPointChart(chart5, N); //GenerateAveragePathLengthErdosChart(chart7, N, N_init, E); GenerateClusteringCoefficientErdosChart(ErdosClusteringChart, N); } }