Ejemplo n.º 1
0
        private static void EadesFRRuntimeVsIterations(int MAX_ITERATIONS = 40000)
        {
            float spring_multiplier = 1.0f; float spring_neutral_distance = 1.0f; float repellant_multiplier = 1.0f; float dampening = 1.0f; float C = 1f;

            foreach (var filename in TestFilePaths())
            {
                var outputStream = new System.IO.StreamWriter(new System.IO.FileInfo("EadesVsFRRuntime" + new System.IO.FileInfo(filename).Name + ".csv").OpenWrite());
                outputStream.WriteLine(PrintCSV(new String[] { "Iterations", "Runtime" }));

                var deltaI = 500;

                for (int iteration = deltaI; iteration < MAX_ITERATIONS; iteration += deltaI)
                {
                    //Multiple runs
                    for (var i = 0; i < RunsPerTest; i++)
                    {
                        var   fruchmanReingold = new FruchtermanReingoldAlgorithm(spring_multiplier, C, repellant_multiplier, iteration, 0f, false);
                        var   eades            = new EadesAlgorithm(spring_multiplier, spring_neutral_distance, repellant_multiplier, dampening, iteration, 0f, false);
                        Graph g         = loadGraph(filename);
                        var   f_results = runner(loadGraph(filename), null, fruchmanReingold);
                        var   e_results = runner(loadGraph(filename), null, eades);
                        if (f_results.iterations != e_results.iterations)
                        {
                            throw new Exception("should never happen");
                        }
                        outputStream.WriteLine(PrintCSV(new String[] { "" + f_results.iterations, "" + f_results.runtime, "" + e_results.runtime }));
                        outputStream.Flush();
                        Console.Write("RuntimeVsIterations: {0}({1}) Iterations: {2}\r", filename, i, f_results.iterations);
                    }
                }
                outputStream.Close();
            }
        }
Ejemplo n.º 2
0
        private static void EadesFRRuntimeVsVertices()
        {
            int   max_iterations = 150;
            float spring_multiplier = 1.0f; float spring_neutral_distance = 1.0f; float repellant_multiplier = 1.0f; float dampening = 1.0f; float C = 1f;
            var   outputStream = new System.IO.StreamWriter(new System.IO.FileInfo("RuntimeVsVertices.csv").OpenWrite());

            outputStream.WriteLine(PrintCSV(new String[] { "Vertices", "Runtime" }));
            foreach (var filename in TestFilePaths())
            {
                // Multiple runs
                for (var i = 0; i < RunsPerTest; i++)
                {
                    Console.Write("RuntimeVsVertices: {0}({1}) Vertices:         \r", filename, i);
                    var   fruchmanReingold = new FruchtermanReingoldAlgorithm(spring_multiplier, C, repellant_multiplier, max_iterations, 0f, false);
                    var   eades            = new EadesAlgorithm(spring_multiplier, spring_neutral_distance, repellant_multiplier, dampening, max_iterations, 0f, false);
                    Graph g         = loadGraph(filename);
                    var   f_results = runner(loadGraph(filename), null, fruchmanReingold);
                    var   e_results = runner(loadGraph(filename), null, eades);
                    if (f_results.iterations != e_results.iterations)
                    {
                        throw new Exception("should never happen");
                    }
                    outputStream.WriteLine(PrintCSV(new String[] { "" + f_results.graph.nodes.Count, "" + f_results.runtime, "" + e_results.runtime }));
                    outputStream.Flush();
                    Console.Write("RuntimeVsVertices: {0}({1}) Vertices: {2}, Time: {3}ms/{4}ms\n", filename, i, f_results.graph.nodes.Count, f_results.runtime, e_results.runtime);
                }
            }
            outputStream.Close();
        }
Ejemplo n.º 3
0
        private static void EadesVsFruchtmanReingold(float spring_multiplier = 1.0f, float spring_neutral_distance = 1.0f, float C = 1f, float repellant_multiplier = 1.0f, float dampening = 1.0f)
        {
            float stabilizationThreshold = 0.1f;
            var   fruchmanReingold       = new FruchtermanReingoldAlgorithm(spring_multiplier, C, repellant_multiplier, int.MaxValue, stabilizationThreshold, true);
            var   eades = new EadesAlgorithm(spring_multiplier, spring_neutral_distance, repellant_multiplier, dampening, int.MaxValue, stabilizationThreshold, true);

            var outputStream = new System.IO.StreamWriter(new System.IO.FileInfo("Algorithms.csv").OpenWrite());

            outputStream.WriteLine(PrintCSV(new String[] { "Eades", "FruchtermanAndReingold" }));


            IInputLoader l = new TestInput();

            foreach (var filename in TestFilePaths())
            {
                for (var i = 0; i < RunsPerTest; i++)
                {
                    Graph g            = l.load(filename);
                    var   resultsEades = runner(l.load(filename), null, eades);
                    var   resultsFR    = runner(l.load(filename), null, fruchmanReingold);

                    outputStream.WriteLine(PrintCSV(new String[] { "" + resultsEades.iterations, "" + resultsFR.iterations }));
                    outputStream.Flush();
                    Console.Write("EadesVsFruchtmanReingold: {0}({1})\r", filename, i);
                }
            }
            outputStream.Close();
        }