Beispiel #1
0
        /// <summary>
        /// The result will get printed out to the console and
        /// you should copy then and get the image elsewhere.
        ///
        /// The printed result will be formatted as json file for convenience.
        /// </summary>
        public void HW4P4Print(
            int n          = 1000,
            double p_start = 0.002,
            double p_end   = 0.02,
            int N          = 10)
        {
            double[]      EdgeDensity = new double[N];
            StringBuilder sb          = new StringBuilder();

            sb.AppendLine("[");

            for (double P = p_start, delta = (p_end - p_start) / N;
                 P <= p_end;
                 P += delta)
            {
                var G = new ColoringGraph(RandGraph(n, P));
                //output.WriteLine($"Ded Distribution with p = {P}; n = {n};");
                sb.AppendLine("{");
                sb.AppendLine($"\t\"p\":{P},");
                sb.AppendLine($"\t\"n\":{n},");
                foreach (KeyValuePair <int, int> kvp in G.GetDegStats())
                {
                    sb.AppendLine($"\t\"{kvp.Key}\": {kvp.Value},");
                }
                sb.Remove(sb.Length - 3, 2);
                sb.AppendLine("},");
            }
            sb.Remove(sb.Length - 3, 2);
            sb.AppendLine("]");
            output.WriteLine(sb.ToString());
        }