private void button2_Click(object sender, EventArgs e) { int N = int.Parse(textBox4.Text); int N_init = int.Parse(textBox6.Text); int E = int.Parse(textBox3.Text);; BarabasiAlbertModel g = new BarabasiAlbertModel(N, false, false, N_init, E); Data.RandomNetwork d = g.Generate(); if (radioButton6.Checked) { if (visualize) { var graphviz = new GraphvizAlgorithm <int, UndirectedEdge <int> >(d.MGraph); string output = graphviz.Generate(new FileDotEngine(), "graph"); pictureBox2.ImageLocation = "graph.png"; } label4.Text = string.Format(@"{0}", d.ClusteringCoefficient()); var degreeDistribuition = d.DegreeDistribuition(); ErdosDistribuitionDegreeChart.Titles.Add(new Title(RandomGraphStrings.DegreeChartTitle)); GenerateDegreeDistribuitionChart(chart1, degreeDistribuition); } if (radioButton5.Checked) { GenerateAveragePathLengthBarabasiChart(chart7, N, N_init, E); GenerateClusteringCoefficientChartBarabasi(chart6, N, N_init, E); } }
private void button1_Click(object sender, EventArgs e) { int N = int.Parse(textBox1.Text); int k = int.Parse(textBox5.Text); //int iter = N; double p = 0.0; double.TryParse(textBox2.Text, NumberStyles.Any, CultureInfo.InvariantCulture, out p); WattsStrogatzModel g = new WattsStrogatzModel(N, false, false, p, k); Data.RandomNetwork d = g.Generate(); if (radioButton4.Checked) { if (visualize) { var graphviz = new GraphvizAlgorithm <int, UndirectedEdge <int> >(d.MGraph); string output = graphviz.Generate(new FileDotEngine(), "graph"); pictureBox1.ImageLocation = "graph.png"; } label4.Text = string.Format(@"{0}", d.ClusteringCoefficient()); var degreeDistribuition = d.DegreeDistribuition(); ErdosDistribuitionDegreeChart.Titles.Add(new Title(RandomGraphStrings.DegreeChartTitle)); GenerateDegreeDistribuitionChart(chart2, degreeDistribuition); } if (radioButton3.Checked) { GenerateAveragePathLengthWattsChart(chart4, N, k); GenerateClusteringCoefficientChart(chart3, N, k); } }
private void GenerateAveragePathLengthBarabasiChart(Chart chart, int N, int Ninit, int Edges) { int iter = 20; double max = 0; double[] datax = new double[iter]; double[] datay = new double[iter]; chart.Series.Clear(); chart.Legends.Clear(); chart.Titles.Clear(); chart.ChartAreas.Clear(); BarabasiAlbertModel g; for (int i = 0; i < iter; i++) { g = new BarabasiAlbertModel(N, false, false, Ninit, Edges * i); Data.RandomNetwork d = g.Generate(); datay[i] = d.AveragePathLength(); datax[i] = (double)i / iter; if (datay[i] > max) { max = datay[i]; } Console.WriteLine("x : " + datax[i] + ", y : " + datay[i]); } ChartSeries(chart, datax, datay, "p = Avg Path Len", iter, N); ChartAreas(chart, "Graph Avg Path Length", max); ChartTitle(chart, ""); }
private void GenerateClusteringCoefficientChart(Chart chart, int N, int k) { int iter = 20; double[] datax = new double[iter]; double[] datay = new double[iter]; chart.Series.Clear(); chart.Legends.Clear(); chart.Titles.Clear(); chart.ChartAreas.Clear(); WattsStrogatzModel g; for (int i = 0; i < iter; i++) { //RandomGraph g = new RandomGraph(N, (double)i/iter); g = new WattsStrogatzModel(N, false, false, (double)i / iter, k); //ErdösRenyiModel g = new ErdösRenyiModel(N, (double)i / iter); Data.RandomNetwork d = g.Generate(); datay[i] = d.ClusteringCoefficient(); datax[i] = (double)i / iter; //Console.WriteLine("x : " + datax[i] + ", y : "+ datay[i]); } ChartSeries(chart, datax, datay, "p = Clust. Coeff.", iter, N); ChartAreas(chart, "Graph Clustering Coefficient", 1); ChartTitle(chart, ""); }