Example #1
0
        static void Main()
        {
            bool isExtraTests = true;

            TestSet set = new TestSet();

            set.TestCases.Add(new BridgeCrossingTestCase(5, new int[] { 1, 2, 5, 10 }, 17));
            set.TestCases.Add(new BridgeCrossingTestCase(5, new int[] { 15, 10, 6, 7 }, 42));
            set.TestCases.Add(new BridgeCrossingTestCase(5, new int[] { 10, 25, 20, 5 }, 60));
            set.TestCases.Add(new BridgeCrossingTestCase(5, new int[] { 100 }, 100));
            set.TestCases.Add(new BridgeCrossingTestCase(5, new int[] { 1, 20 }, 20));
            set.TestCases.Add(new BridgeCrossingTestCase(5, new int[] { 1, 10, 100 }, 111));
            set.TestCases.Add(new BridgeCrossingTestCase(5, new int[] { 2, 2, 2, 2, 2 }, 14));
            set.TestCases.Add(new BridgeCrossingTestCase(5, new int[] { 1, 2, 3, 4, 5 }, 16));
            set.TestCases.Add(new BridgeCrossingTestCase(5, new int[] { 1, 1, 5, 5, 10, 10 }, 22));
            set.TestCases.Add(new BridgeCrossingTestCase(5, GenerateTestArray(5, 555), 284));
            set.TestCases.Add(new BridgeCrossingTestCase(5, GenerateTestArray(6, 666), 346));
            set.TestCases.Add(new BridgeCrossingTestCase(5, GenerateTestArray(7, 777), 216));
            Console.WriteLine("\nBasic tests");
            set.PreformTests(verbose: true, checkTimeLimit: false);

            if (isExtraTests)
            {
                TestSet set2 = new TestSet();
                set2.TestCases.Add(new BridgeCrossingTestCase(3, GenerateTestArray(8, 888), 313));
                set2.TestCases.Add(new BridgeCrossingTestCase(30, GenerateTestArray(9, 999), 453));
                Console.WriteLine("\nExtra tests");
                set2.PreformTests(verbose: true, checkTimeLimit: true);
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            DataContractSerializer dcs = new DataContractSerializer(typeof(TestSet), new Type[] { typeof(ClosestPointsTestCase) });
            FileStream             fs;

            Console.WriteLine("Brute force algorithm tests:");
            fs = new FileStream("STB.dat", FileMode.Open);
            TestSet simpleTestsBrute = (TestSet)dcs.ReadObject(fs);

            fs.Close();
            simpleTestsBrute.PreformTests(true, false);

            Console.WriteLine("Sweep line algorithm tests:");
            fs = new FileStream("ST.dat", FileMode.Open);
            TestSet simpleTests = (TestSet)dcs.ReadObject(fs);

            fs.Close();
            simpleTests.PreformTests(true, false);

            Console.WriteLine("Sweep line algorithm performance tests:");
            fs = new FileStream("PT.dat", FileMode.Open);
            TestSet performanceTests = (TestSet)dcs.ReadObject(fs);

            fs.Close();
            performanceTests.PreformTests(true, true);

            return;
        }
Example #3
0
        static void Main()
        {
            TestSet changeMakingNoLimits = new TestSet();

            changeMakingNoLimits.TestCases.Add(new ChangeMakingNoLimitsTestCase(5, null, 10, new int[] { 5, 1, 2 }, new int[] { 2, 0, 0 }));
            changeMakingNoLimits.TestCases.Add(new ChangeMakingNoLimitsTestCase(5, null, 123, new int[] { 1, 2, 5, 10, 20, 50, 100, 200 }, new int[] { 1, 1, 0, 0, 1, 0, 1, 0 }));
            changeMakingNoLimits.TestCases.Add(new ChangeMakingNoLimitsTestCase(5, null, 123, new int[] { 2, 5, 10, 20, 50, 100, 200 }, new int[] { 4, 1, 0, 1, 0, 1, 0 }));
            changeMakingNoLimits.TestCases.Add(new ChangeMakingNoLimitsTestCase(5, null, 23, new int[] { 1 }, new int[] { 23 }));
            changeMakingNoLimits.TestCases.Add(new ChangeMakingNoLimitsTestCase(5, null, 23, new int[] { 2 }, null));
            changeMakingNoLimits.TestCases.Add(new ChangeMakingNoLimitsTestCase(5, null, 23, new int[] { 50 }, null));

            TestSet changeMakingLimits = new TestSet();

            changeMakingLimits.TestCases.Add(new ChangeMakingLimitsTestCase(5, null, 10, new int[] { 5, 1, 2 }, new int[] { 1, 20, 10 }, new int[] { 1, 1, 2 }));

            changeMakingLimits.TestCases.Add(new ChangeMakingLimitsTestCase(5, null, 123, new int[] { 1, 2, 5, 10, 20, 50, 100, 200 },
                                                                            new int[] { 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999 },
                                                                            new int[] { 1, 1, 0, 0, 1, 0, 1, 0 }));

            changeMakingLimits.TestCases.Add(new ChangeMakingLimitsTestCase(5, null, 123, new int[] { 2, 5, 10, 20, 50, 100, 200 },
                                                                            new int[] { 99999, 99999, 99999, 99999, 99999, 99999, 99999 },
                                                                            new int[] { 4, 1, 1, 0, 0, 1, 0 }));

            changeMakingLimits.TestCases.Add(new ChangeMakingLimitsTestCase(5, null, 123, new int[] { 1, 2, 5, 10, 20, 50, 100, 200 },
                                                                            new int[] { 0, 99999, 99999, 99999, 99999, 99999, 99999, 99999 },
                                                                            new int[] { 0, 4, 1, 1, 0, 0, 1, 0 }));

            changeMakingLimits.TestCases.Add(new ChangeMakingLimitsTestCase(5, null, 123, new int[] { 1, 2, 5, 10, 20, 50, 100, 200 },
                                                                            new int[] { 99999, 99999, 3, 4, 3, 0, 0, 99999 },
                                                                            new int[] { 0, 4, 3, 4, 3, 0, 0, 0 }));

            changeMakingLimits.TestCases.Add(new ChangeMakingLimitsTestCase(5, null, 23, new int[] { 1, 2, 5 },
                                                                            new int[] { 99999, 99999, 3 },
                                                                            new int[] { 0, 4, 3 }));

            changeMakingLimits.TestCases.Add(new ChangeMakingLimitsTestCase(5, null, 23, new int[] { 5, 1, 2 },
                                                                            new int[] { 2, 3, 5 },
                                                                            new int[] { 2, 3, 5 }));

            changeMakingLimits.TestCases.Add(new ChangeMakingLimitsTestCase(5, null, 23, new int[] { 5, 5, 1, 2 },
                                                                            new int[] { 3, 2, 3, 3 },
                                                                            new int[] { 3, 1, 1, 1 }));

            changeMakingLimits.TestCases.Add(new ChangeMakingLimitsTestCase(5, null, 23, new int[] { 2 }, new int[15], null));
            changeMakingLimits.TestCases.Add(new ChangeMakingLimitsTestCase(5, null, 23, new int[] { 50 }, new int[1], null));
            changeMakingLimits.TestCases.Add(new ChangeMakingLimitsTestCase(5, null, 23, new int[] { 1 }, new int[20], null));

            changeMakingLimits.TestCases.Add(new ChangeMakingLimitsTestCase(5, null, 141, new int[] { 2, 137, 65, 35, 30, 9, 123, 81, 71 },
                                                                            new int[] { 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                                                                            new int[] { 1, 0, 1, 1, 1, 1, 0, 0, 0 }));

            Console.WriteLine("\nChange Making without coins limits");
            changeMakingNoLimits.PreformTests(verbose: true, checkTimeLimit: false);

            Console.WriteLine("\nChange Making with coins limits");
            changeMakingLimits.PreformTests(verbose: true, checkTimeLimit: false);
        }
Example #4
0
        static void Main()
        {
            if (Graphs.GraphLibraryVersion.ToString() != "7.0.3")
            {
                Console.WriteLine("\nPobierz nową wersję biblioteki\n");
                return;
            }

            var simpleTests = new TestSet();

            simpleTests.TestCases.Add(CreateBasicTest1());
            simpleTests.TestCases.Add(CreateBasicTest2());
            simpleTests.TestCases.Add(CreateBasicTest3());
            simpleTests.TestCases.Add(CreateBasicTest4());
            simpleTests.TestCases.Add(CreateBasicTest5());
            simpleTests.TestCases.Add(CreateBasicTest6());
            simpleTests.TestCases.Add(CreateBasicTest7());
            simpleTests.TestCases.Add(CreateBasicTest8());
            Console.WriteLine("Standard tests:");
            simpleTests.PreformTests(true, false);


            var fullTests = new TestSet();

            fullTests.TestCases.Add(CreateFullTestCase1());
            fullTests.TestCases.Add(CreateFullTestCase2());
            fullTests.TestCases.Add(CreateFullTestCase3());
            fullTests.TestCases.Add(CreateFullTestCase4());
            fullTests.TestCases.Add(CreateFullTestCase5());
            fullTests.TestCases.Add(CreateFullTestCase6());
            fullTests.TestCases.Add(CreateFullTestCase7());
            fullTests.TestCases.Add(CreateFullTestCase8());
            fullTests.TestCases.Add(CreateFullTestCase9());
            fullTests.TestCases.Add(CreateFullTestCase10());
            fullTests.TestCases.Add(CreateFullTestCase11());
            Console.WriteLine("Tests with limits:");
            fullTests.PreformTests(true, false);


            var cappedTests = new TestSet();

            cappedTests.TestCases.Add(CreateCappedTestCase1());
            cappedTests.TestCases.Add(CreateCappedTestCase2());
            cappedTests.TestCases.Add(CreateCappedTestCase3());
            cappedTests.TestCases.Add(CreateCappedTestCase4());
            cappedTests.TestCases.Add(CreateCappedTestCase5());
            cappedTests.TestCases.Add(CreateCappedTestCase6());
            cappedTests.TestCases.Add(CreateCappedTestCase7());
            cappedTests.TestCases.Add(CreateCappedTestCase8());
            cappedTests.TestCases.Add(CreateCappedTestCase9());
            cappedTests.TestCases.Add(CreateCappedTestCase10());
            Console.WriteLine("Test with capped production:");
            cappedTests.PreformTests(true, false);
        }
Example #5
0
        static void Main()
        {
            TestSet finalVelocitiesTests = new TestSet();

            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, new int[] { 0 }, 0, 0));
            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, new int[] { 10 }, 10, 10));
            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, new int[] { 10, 3, 5, 4 }, 2, 22));
            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, new int[] { 4, 11, 5, 5, 5 }, 0, 30));
            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, new int[] { 10, 10, 5, 3, 1 }, 1, 29));
            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, new int[] { 10, 10, 5, 3, 1, 9, 24, 3, 4, 19, 18, 7, 7, 8, 10, 5 }, 1, 143));
            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, new int[] { 7, 10, 2, 18, 4, 6, 6 }, 1, 53));
            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, GenerateTestArray(20, 1024), 1, 1101));
            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, GenerateTestArray(100, 1024), 0, 4650));
            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, GenerateTestArray(100, 123424), 1, 5337));
            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, GenerateTestArray(1000, 123424), 1, 49209));

            Console.WriteLine("\nFinal velocities tests");
            finalVelocitiesTests.PreformTests(verbose: true, checkTimeLimit: false);


            TestSet journeyVelocitiesTests = new TestSet();

            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, new int[] { 10 }, 10, 10, true));
            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, new int[] { 10, 1, 1, 1 }, 7, 13, true));
            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, new int[] { 10, 3, 5, 4 }, 2, 22, true));
            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, new int[] { 4, 11, 5, 5, 5 }, 0, 30, true));
            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, new int[] { 10, 10, 5, 3, 1 }, 0, 29, true));
            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, new int[] { 5, 5, 10, 23, 45, 2, 1, 23, 9, 0, 8, 4, 1, 24, 86, 5, 6, 100, 353, 4, 5, 67, 32, 45, 23, 34, 56, 32, 23 }, 0, 1031, true));
            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, GenerateTestArray(20, 1024), 0, 1101, true));
            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, GenerateTestArray(100, 1024), 0, 4650, true));
            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, GenerateTestArray(100, 123424), 0, 5337, true));
            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, GenerateTestArray(1000, 123424), 0, 49209, true));
            int[] x = { 2, 2 }, y = GenerateTestArray(1000, 123424), z = new int[x.Length + y.Length];
            x.CopyTo(z, 0);
            y.CopyTo(z, x.Length);
            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, z, 0, 49213, true));



            Console.WriteLine("\nJourney velocities tests");
            journeyVelocitiesTests.PreformTests(verbose: true, checkTimeLimit: false);
        }
Example #6
0
        static void Main(string[] args)
        {
            Graph g1, g2, g3, g4, g5, g6;

            // test 1 -- graf pełny
            g1 = new AdjacencyMatrixGraph(false, 20);
            for (int i = 0; i < 20; ++i)
            {
                for (int j = i + 1; j < 20; ++j)
                {
                    g1.AddEdge(i, j);
                }
            }

            //test 2 -- graf pusty
            g2 = new AdjacencyMatrixGraph(false, 20);

            // test 3
            g3 = new AdjacencyMatrixGraph(false, 8);

            for (int i = 1; i < 6; ++i)
            {
                g3.AddEdge(i - 1, i);
            }
            g3.AddEdge(6, 1);
            g3.AddEdge(7, 4);

            // test 4 -- K_n,n - skojarzenie doskonałe, nieparzyste i parzyste w osobnych klasach dwudzielności

            g4 = new AdjacencyMatrixGraph(false, 20);
            for (int i = 0; i < 10; ++i)
            {
                for (int j = 0; j < 10; ++j)
                {
                    if (i != j)
                    {
                        g4.AddEdge(2 * i, 2 * j + 1);
                    }
                }
            }

            // test 5 -- prismoid - przypadek dla SL

            g5 = new AdjacencyMatrixGraph(false, 8);

            g5.AddEdge(0, 1);
            g5.AddEdge(0, 2);
            g5.AddEdge(0, 4);
            g5.AddEdge(0, 6);
            g5.AddEdge(1, 2);
            g5.AddEdge(1, 3);
            g5.AddEdge(1, 7);
            g5.AddEdge(2, 3);
            g5.AddEdge(2, 4);
            g5.AddEdge(3, 5);
            g5.AddEdge(3, 7);
            g5.AddEdge(4, 5);
            g5.AddEdge(4, 6);
            g5.AddEdge(5, 6);
            g5.AddEdge(5, 7);
            g5.AddEdge(6, 7);

            //http://cs.stackexchange.com/questions/42973/counter-example-to-graph-coloring-heuristic-using-bfs
            g6 = new AdjacencyMatrixGraph(false, 6);

            g6.AddEdge(0, 1);
            g6.AddEdge(0, 2);
            g6.AddEdge(1, 3);
            g6.AddEdge(3, 4);
            g6.AddEdge(3, 5);
            g6.AddEdge(2, 4);
            g6.AddEdge(2, 5);
            g6.AddEdge(4, 5);

            RandomGraphGenerator rgg = new RandomGraphGenerator();

            rgg.SetSeed(111);
            Graph g7 = rgg.UndirectedCycle(typeof(AdjacencyMatrixGraph), 100);

            rgg.SetSeed(222);
            Graph g8 = rgg.UndirectedGraph(typeof(AdjacencyMatrixGraph), 100, 0.3);

            rgg.SetSeed(333);
            Graph g9 = rgg.UndirectedGraph(typeof(AdjacencyMatrixGraph), 100, 0.5);

            rgg.SetSeed(444);
            Graph g10 = rgg.UndirectedGraph(typeof(AdjacencyMatrixGraph), 100, 0.7);

            rgg.SetSeed(666);
            Graph g11 = rgg.UndirectedGraph(typeof(AdjacencyListsGraph <SimpleAdjacencyList>), 17000, 0.001);

            Graph[] graphs = { g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11 };

            DataContractSerializer dcs    = new DataContractSerializer(typeof(ProperResult[]));
            FileStream             greedy = new FileStream("greedy.dat", FileMode.Open);

            ProperResult[] greedyProperResults = (ProperResult[])dcs.ReadObject(greedy);
            greedy.Close();
            FileStream bfs = new FileStream("bfs.dat", FileMode.Open);

            ProperResult[] bfsProperResults = (ProperResult[])dcs.ReadObject(bfs);
            bfs.Close();
            FileStream back = new FileStream("back.dat", FileMode.Open);

            ProperResult[] backProperResults = (ProperResult[])dcs.ReadObject(back);
            back.Close();
            FileStream color = new FileStream("color.dat", FileMode.Open);

            ProperResult[] colorProperResults = (ProperResult[])dcs.ReadObject(color);
            color.Close();
            FileStream incremental = new FileStream("incremental.dat", FileMode.Open);

            ProperResult[] incrementalProperResults = (ProperResult[])dcs.ReadObject(incremental);
            incremental.Close();

            TestSet setSG = new TestSet();

            setSG.TestCases.Add(new GreedyColoringGraphColoringTestCase(5, g1, greedyProperResults[0]));
            setSG.TestCases.Add(new GreedyColoringGraphColoringTestCase(5, g2, greedyProperResults[1]));
            setSG.TestCases.Add(new GreedyColoringGraphColoringTestCase(5, g3, greedyProperResults[2]));
            setSG.TestCases.Add(new GreedyColoringGraphColoringTestCase(5, g4, greedyProperResults[3]));
            setSG.TestCases.Add(new GreedyColoringGraphColoringTestCase(5, g5, greedyProperResults[4]));
            setSG.TestCases.Add(new GreedyColoringGraphColoringTestCase(5, g6, greedyProperResults[5]));
            setSG.TestCases.Add(new GreedyColoringGraphColoringTestCase(5, g7, greedyProperResults[6]));
            setSG.TestCases.Add(new GreedyColoringGraphColoringTestCase(5, g8, greedyProperResults[7]));
            setSG.TestCases.Add(new GreedyColoringGraphColoringTestCase(5, g9, greedyProperResults[8]));
            setSG.TestCases.Add(new GreedyColoringGraphColoringTestCase(5, g10, greedyProperResults[9]));
            setSG.TestCases.Add(new GreedyColoringGraphColoringTestCase(5, g11, greedyProperResults[10]));
            Console.WriteLine("\nGreedy Coloring");
            setSG.PreformTests(verbose: true, checkTimeLimit: false);

            TestSet setBFS = new TestSet();

            setBFS.TestCases.Add(new BFSGraphColoringTestCase(5, g1, bfsProperResults[0]));
            setBFS.TestCases.Add(new BFSGraphColoringTestCase(5, g2, bfsProperResults[1]));
            setBFS.TestCases.Add(new BFSGraphColoringTestCase(5, g3, bfsProperResults[2]));
            setBFS.TestCases.Add(new BFSGraphColoringTestCase(5, g4, bfsProperResults[3]));
            setBFS.TestCases.Add(new BFSGraphColoringTestCase(5, g5, bfsProperResults[4]));
            setBFS.TestCases.Add(new BFSGraphColoringTestCase(5, g6, bfsProperResults[5]));
            setBFS.TestCases.Add(new BFSGraphColoringTestCase(5, g7, bfsProperResults[6]));
            setBFS.TestCases.Add(new BFSGraphColoringTestCase(5, g8, bfsProperResults[7]));
            setBFS.TestCases.Add(new BFSGraphColoringTestCase(5, g9, bfsProperResults[8]));
            setBFS.TestCases.Add(new BFSGraphColoringTestCase(5, g10, bfsProperResults[9]));
            setBFS.TestCases.Add(new BFSGraphColoringTestCase(5, g11, bfsProperResults[10]));
            Console.WriteLine("\nBFS Coloring");
            setBFS.PreformTests(verbose: true, checkTimeLimit: false);

            TestSet setLBD = new TestSet();

            setLBD.TestCases.Add(new LargestBackDegreeGraphColoringTestCase(5, g1, backProperResults[0]));
            setLBD.TestCases.Add(new LargestBackDegreeGraphColoringTestCase(5, g2, backProperResults[1]));
            setLBD.TestCases.Add(new LargestBackDegreeGraphColoringTestCase(5, g3, backProperResults[2]));
            setLBD.TestCases.Add(new LargestBackDegreeGraphColoringTestCase(5, g4, backProperResults[3]));
            setLBD.TestCases.Add(new LargestBackDegreeGraphColoringTestCase(5, g5, backProperResults[4]));
            setLBD.TestCases.Add(new LargestBackDegreeGraphColoringTestCase(5, g6, backProperResults[5]));
            setLBD.TestCases.Add(new LargestBackDegreeGraphColoringTestCase(5, g7, backProperResults[6]));
            setLBD.TestCases.Add(new LargestBackDegreeGraphColoringTestCase(5, g8, backProperResults[7]));
            setLBD.TestCases.Add(new LargestBackDegreeGraphColoringTestCase(5, g9, backProperResults[8]));
            setLBD.TestCases.Add(new LargestBackDegreeGraphColoringTestCase(5, g10, backProperResults[9]));
            setLBD.TestCases.Add(new LargestBackDegreeGraphColoringTestCase(5, g11, backProperResults[10]));
            Console.WriteLine("\nLargest Back Degree");
            setLBD.PreformTests(verbose: true, checkTimeLimit: false);

            TestSet setDS = new TestSet();

            setDS.TestCases.Add(new ColorDegreeOrderingGraphColoringTestCase(5, g1, colorProperResults[0]));
            setDS.TestCases.Add(new ColorDegreeOrderingGraphColoringTestCase(5, g2, colorProperResults[1]));
            setDS.TestCases.Add(new ColorDegreeOrderingGraphColoringTestCase(5, g3, colorProperResults[2]));
            setDS.TestCases.Add(new ColorDegreeOrderingGraphColoringTestCase(5, g4, colorProperResults[3]));
            setDS.TestCases.Add(new ColorDegreeOrderingGraphColoringTestCase(5, g5, colorProperResults[4]));
            setDS.TestCases.Add(new ColorDegreeOrderingGraphColoringTestCase(5, g6, colorProperResults[5]));
            setDS.TestCases.Add(new ColorDegreeOrderingGraphColoringTestCase(5, g7, colorProperResults[6]));
            setDS.TestCases.Add(new ColorDegreeOrderingGraphColoringTestCase(5, g8, colorProperResults[7]));
            setDS.TestCases.Add(new ColorDegreeOrderingGraphColoringTestCase(5, g9, colorProperResults[8]));
            setDS.TestCases.Add(new ColorDegreeOrderingGraphColoringTestCase(5, g10, colorProperResults[9]));
            setDS.TestCases.Add(new ColorDegreeOrderingGraphColoringTestCase(5, g11, colorProperResults[10]));
            Console.WriteLine("\nColor Degree Ordering");
            setDS.PreformTests(verbose: true, checkTimeLimit: false);

            TestSet setInc = new TestSet();

            setInc.TestCases.Add(new IncrementalGraphColoringTestCase(5, g1, incrementalProperResults[0]));
            setInc.TestCases.Add(new IncrementalGraphColoringTestCase(5, g2, incrementalProperResults[1]));
            setInc.TestCases.Add(new IncrementalGraphColoringTestCase(5, g3, incrementalProperResults[2]));
            setInc.TestCases.Add(new IncrementalGraphColoringTestCase(5, g4, incrementalProperResults[3]));
            setInc.TestCases.Add(new IncrementalGraphColoringTestCase(5, g5, incrementalProperResults[4]));
            setInc.TestCases.Add(new IncrementalGraphColoringTestCase(5, g6, incrementalProperResults[5]));
            setInc.TestCases.Add(new IncrementalGraphColoringTestCase(5, g7, incrementalProperResults[6]));
            setInc.TestCases.Add(new IncrementalGraphColoringTestCase(5, g8, incrementalProperResults[7]));
            setInc.TestCases.Add(new IncrementalGraphColoringTestCase(5, g9, incrementalProperResults[8]));
            setInc.TestCases.Add(new IncrementalGraphColoringTestCase(5, g10, incrementalProperResults[9]));
            setInc.TestCases.Add(new IncrementalGraphColoringTestCase(5, g11, incrementalProperResults[10]));
            Console.WriteLine("\nIncremental");
            setInc.PreformTests(verbose: true, checkTimeLimit: false);
        }
        static void Main(string[] args)
        {
            GraphExport          ge  = new GraphExport();
            RandomGraphGenerator rgg = new RandomGraphGenerator();

            Graph[] directedGraphs = new Graph[8];
            directedGraphs[0] = new AdjacencyListsGraph <AVLAdjacencyList>(true, 3)
            {
                new Edge(0, 1), new Edge(1, 2), new Edge(2, 0)
            };
            directedGraphs[1] = new AdjacencyListsGraph <SimpleAdjacencyList>(true, 3)
            {
                new Edge(0, 1), new Edge(1, 2), new Edge(2, 1)
            };
            directedGraphs[2] = new AdjacencyMatrixGraph(true, 4)
            {
                new Edge(0, 1), new Edge(0, 2), new Edge(1, 3), new Edge(2, 3)
            };
            directedGraphs[3] = new AdjacencyListsGraph <HashTableAdjacencyList>(true, 10);
            directedGraphs[4] = new AdjacencyMatrixGraph(true, 10)
            {
                new Edge(0, 1), new Edge(0, 2), new Edge(0, 3), new Edge(2, 4), new Edge(2, 5), new Edge(2, 6),
                new Edge(5, 7), new Edge(5, 8), new Edge(5, 9), new Edge(6, 5), new Edge(7, 8), new Edge(8, 2)
            };
            rgg.SetSeed(111);
            directedGraphs[5] = rgg.DirectedGraph(typeof(AdjacencyMatrixGraph), 100, 0.2);
            rgg.SetSeed(222);
            directedGraphs[6] = rgg.DirectedCycle(typeof(AdjacencyListsGraph <SimpleAdjacencyList>), 1000);
            rgg.SetSeed(333);
            directedGraphs[7] = rgg.DAG(typeof(AdjacencyMatrixGraph), 200, 0.2, 1, 1);

            TestSet findCycleDirected = new TestSet();

            findCycleDirected.TestCases.Add(new FindCycleTestCase(5, null, directedGraphs[0], true));
            findCycleDirected.TestCases.Add(new FindCycleTestCase(5, null, directedGraphs[1], true));
            findCycleDirected.TestCases.Add(new FindCycleTestCase(5, null, directedGraphs[2], false));
            findCycleDirected.TestCases.Add(new FindCycleTestCase(5, null, directedGraphs[3], false));
            findCycleDirected.TestCases.Add(new FindCycleTestCase(5, null, directedGraphs[4], true));
            findCycleDirected.TestCases.Add(new FindCycleTestCase(5, null, directedGraphs[5], true));
            findCycleDirected.TestCases.Add(new FindCycleTestCase(5, null, directedGraphs[6], true));
            findCycleDirected.TestCases.Add(new FindCycleTestCase(5, null, directedGraphs[7], false));

            Graph[] undirectedGraphs = new Graph[6];
            undirectedGraphs[0] = new AdjacencyListsGraph <AVLAdjacencyList>(false, 3)
            {
                new Edge(0, 1), new Edge(1, 2), new Edge(2, 0)
            };
            undirectedGraphs[1] = new AdjacencyListsGraph <SimpleAdjacencyList>(false, 4)
            {
                new Edge(0, 1), new Edge(1, 2), new Edge(2, 3), new Edge(3, 1)
            };
            undirectedGraphs[2] = new AdjacencyListsGraph <HashTableAdjacencyList>(false, 10);
            undirectedGraphs[3] = new AdjacencyMatrixGraph(false, 10)
            {
                new Edge(0, 1), new Edge(0, 2), new Edge(0, 3), new Edge(2, 4), new Edge(2, 5), new Edge(2, 6),
                new Edge(5, 7), new Edge(5, 8), new Edge(5, 9), new Edge(8, 2)
            };
            rgg.SetSeed(444);
            undirectedGraphs[4] = rgg.UndirectedGraph(typeof(AdjacencyMatrixGraph), 100, 0.2);
            rgg.SetSeed(555);
            undirectedGraphs[5] = rgg.TreeGraph(typeof(AdjacencyListsGraph <SimpleAdjacencyList>), 1000, 1.0);

            TestSet findCycleUndirected = new TestSet();

            findCycleUndirected.TestCases.Add(new FindCycleTestCase(5, null, undirectedGraphs[0], true));
            findCycleUndirected.TestCases.Add(new FindCycleTestCase(5, null, undirectedGraphs[1], true));
            findCycleUndirected.TestCases.Add(new FindCycleTestCase(5, null, undirectedGraphs[2], false));
            findCycleUndirected.TestCases.Add(new FindCycleTestCase(5, null, undirectedGraphs[3], true));
            findCycleUndirected.TestCases.Add(new FindCycleTestCase(5, null, undirectedGraphs[4], true));
            findCycleUndirected.TestCases.Add(new FindCycleTestCase(5, null, undirectedGraphs[5], false));

            Graph[] trees = new Graph[10];
            trees[0] = new AdjacencyListsGraph <AVLAdjacencyList>(false, 3)
            {
                new Edge(0, 1), new Edge(1, 2)
            };
            trees[1] = new AdjacencyListsGraph <SimpleAdjacencyList>(false, 4)
            {
                new Edge(0, 1), new Edge(1, 2), new Edge(2, 3)
            };
            trees[2] = new AdjacencyListsGraph <HashTableAdjacencyList>(false, 1);
            trees[3] = new AdjacencyListsGraph <HashTableAdjacencyList>(false, 2)
            {
                new Edge(0, 1)
            };
            trees[4] = new AdjacencyMatrixGraph(false, 5)
            {
                new Edge(1, 3), new Edge(2, 4)
            };
            trees[5] = new AdjacencyMatrixGraph(true, 3)
            {
                new Edge(0, 1), new Edge(0, 2)
            };
            rgg.SetSeed(777);
            trees[6] = rgg.UndirectedGraph(typeof(AdjacencyMatrixGraph), 100, 0.2);
            rgg.SetSeed(888);
            trees[7] = rgg.TreeGraph(typeof(AdjacencyListsGraph <SimpleAdjacencyList>), 1000, 1.0);
            rgg.SetSeed(999);
            trees[8] = rgg.TreeGraph(typeof(AdjacencyListsGraph <SimpleAdjacencyList>), 1001, 1.0);
            trees[9] = new AdjacencyListsGraph <SimpleAdjacencyList>(false, 10);
            for (int i = 1; i < 10; ++i)
            {
                trees[9].AddEdge(i - 1, i);
            }

            TestSet treeCenter = new TestSet();

            treeCenter.TestCases.Add(new TreeCenterTestCase(5, null, trees[0], true, new int[] { 1 }));
            treeCenter.TestCases.Add(new TreeCenterTestCase(5, null, trees[1], true, new int[] { 1, 2 }));
            treeCenter.TestCases.Add(new TreeCenterTestCase(5, null, trees[2], true, new int[] { 0 }));
            treeCenter.TestCases.Add(new TreeCenterTestCase(5, null, trees[3], true, new int[] { 0, 1 }));
            treeCenter.TestCases.Add(new TreeCenterTestCase(5, null, trees[4], false, null));
            treeCenter.TestCases.Add(new TreeCenterTestCase(5, new ArgumentException(), trees[5], false, null));
            treeCenter.TestCases.Add(new TreeCenterTestCase(5, null, trees[6], false, null));
            treeCenter.TestCases.Add(new TreeCenterTestCase(5, null, trees[7], true, new int[] { 305, 786 }));
            treeCenter.TestCases.Add(new TreeCenterTestCase(5, null, trees[8], true, new int[] { 60 }));
            treeCenter.TestCases.Add(new TreeCenterTestCase(5, null, trees[9], true, new int[] { 4, 5 }));

            //
            // Odkomentuj odpowiednią linię aby zobaczyć wybrany graf
            // Pamiętaj, że przykłady numerowane są od 1
            //
//        ge.Export(directedGraphs[0]);
//        ge.Export(directedGraphs[1]);
//        ge.Export(directedGraphs[2]);
//        ge.Export(directedGraphs[3]);
//        ge.Export(directedGraphs[4]);
//        ge.Export(directedGraphs[5]);
//        ge.Export(directedGraphs[6]);
//        ge.Export(directedGraphs[7]);
//        ge.Export(undirectedGraphs[0]);
//        ge.Export(undirectedGraphs[1]);
//        ge.Export(undirectedGraphs[2]);
//        ge.Export(undirectedGraphs[3]);
//        ge.Export(undirectedGraphs[4]);
//        ge.Export(undirectedGraphs[5]);
//        ge.Export(trees[0]);
//        ge.Export(trees[1]);
//        ge.Export(trees[2]);
//        ge.Export(trees[3]);
//        ge.Export(trees[4]);
//        ge.Export(trees[5]);
//        ge.Export(trees[6]);
//        ge.Export(trees[7]);
//        ge.Export(trees[8]);

            Console.WriteLine("\nCycle Finding\n");

            FindCycleTestCase.ResultOnly = true;
            Console.WriteLine("\nDirected Graphs - result only");
            findCycleDirected.PreformTests(verbose: true, checkTimeLimit: false);
            Console.WriteLine("\nUndirected Graphs - result only");
            findCycleUndirected.PreformTests(verbose: true, checkTimeLimit: false);

            FindCycleTestCase.ResultOnly = false;
            Console.WriteLine("\nDirected Graphs - full funcionality");
            findCycleDirected.PreformTests(verbose: true, checkTimeLimit: false, forceExecution: false);
            Console.WriteLine("\nUndirected Graphs - full funcionality");
            findCycleUndirected.PreformTests(verbose: true, checkTimeLimit: false, forceExecution: false);

            Console.WriteLine("\nTree Center\n");
            TreeCenterTestCase.ResultOnly = true;
            Console.WriteLine("\nResult only");
            treeCenter.PreformTests(verbose: true, checkTimeLimit: false);
            Console.WriteLine("\nFull funcionality");
            TreeCenterTestCase.ResultOnly = false;
            treeCenter.PreformTests(verbose: true, checkTimeLimit: false, forceExecution: false);
        }
Example #8
0
        static void Main(string[] args)
        {
            TestSet cyclePartitionTests = new TestSet();
            TestSet matchingTests       = new TestSet();

            Graph C4 = new AdjacencyMatrixGraph(false, 4);

            C4.AddEdge(0, 1);
            C4.AddEdge(0, 3);
            C4.AddEdge(2, 1);
            C4.AddEdge(2, 3);
            cyclePartitionTests.TestCases.Add(new CyclePartitionTestCase(5, null, C4));
            matchingTests.TestCases.Add(new PerfectMatchingTestCase(5, null, C4));

            Graph DoubleC4 = new AdjacencyMatrixGraph(false, 8);

            DoubleC4.AddEdge(0, 1);
            DoubleC4.AddEdge(0, 3);
            DoubleC4.AddEdge(2, 1);
            DoubleC4.AddEdge(2, 3);

            DoubleC4.AddEdge(4, 5);
            DoubleC4.AddEdge(4, 7);
            DoubleC4.AddEdge(6, 5);
            DoubleC4.AddEdge(6, 7);

            cyclePartitionTests.TestCases.Add(new CyclePartitionTestCase(5, null, DoubleC4));
            matchingTests.TestCases.Add(new PerfectMatchingTestCase(5, null, DoubleC4));

            Graph matching = new AdjacencyListsGraph <SimpleAdjacencyList>(false, 20);

            for (int i = 0; i < 10; i++)
            {
                matching.AddEdge((3 * i) % 20, (3 * i + 10) % 20);
            }

            matchingTests.TestCases.Add(new PerfectMatchingTestCase(5, null, matching));

            Graph tripleC6 = new AdjacencyListsGraph <HashTableAdjacencyList>(false, 18);

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 6; j++)
                {
                    tripleC6.AddEdge(6 * i + j, 6 * i + (j + 1) % 6);
                }
            }

            cyclePartitionTests.TestCases.Add(new CyclePartitionTestCase(5, null, tripleC6));
            matchingTests.TestCases.Add(new PerfectMatchingTestCase(5, null, tripleC6));

            Graph C4free = new AdjacencyListsGraph <HashTableAdjacencyList>(false, 54);

            for (int c = 0; c < 3; c++)
            {
                for (int i = 0; i < 3; i++)
                {
                    for (int j = 0; j < 6; j++)
                    {
                        C4free.AddEdge(18 * c + 6 * i + j, 18 * c + 6 * i + (j + 1) % 6);
                    }
                }
            }
            for (int c = 0; c < 3; c++)
            {
                for (int i = 0; i < 3; i++)
                {
                    for (int j = 0; j < 6; j += 2)
                    {
                        C4free.AddEdge(18 * c + 6 * i + j, 18 * c + 6 * ((i + 1) % 3) + (j + 1) % 6);
                    }
                }
            }
            for (int c = 0; c < 3; c++)
            {
                for (int i = 0; i < 3; i++)
                {
                    for (int j = 0; j < 6; j += 2)
                    {
                        C4free.AddEdge(18 * c + 6 * i + j, 18 * ((c + 1) % 3) + 6 * ((i + 1) % 3) + (j + 1) % 6);
                    }
                }
            }

            cyclePartitionTests.TestCases.Add(new CyclePartitionTestCase(5, null, C4free));
            matchingTests.TestCases.Add(new PerfectMatchingTestCase(5, null, C4free));

            cyclePartitionTests.TestCases.Add(new CyclePartitionTestCase(5, null, randomRegularBipartite(100, 10, 13)));
            cyclePartitionTests.TestCases.Add(new CyclePartitionTestCase(5, null, randomRegularBipartite(100, 40, 14)));
            cyclePartitionTests.TestCases.Add(new CyclePartitionTestCase(5, null, randomRegularBipartite(200, 8, 15)));
            cyclePartitionTests.TestCases.Add(new CyclePartitionTestCase(5, null, randomRegularBipartite(100, 16, 16)));


            matchingTests.TestCases.Add(new PerfectMatchingTestCase(5, null, randomRegularBipartite(300, 4, 13)));
            matchingTests.TestCases.Add(new PerfectMatchingTestCase(5, null, randomRegularBipartite(200, 8, 14)));
            matchingTests.TestCases.Add(new PerfectMatchingTestCase(5, null, randomRegularBipartite(200, 16, 15)));
            matchingTests.TestCases.Add(new PerfectMatchingTestCase(5, null, randomRegularBipartite(100, 32, 16)));

            Console.WriteLine("***************************   Cycle partition tests  ***************************");
            cyclePartitionTests.PreformTests(true, false);

            Console.WriteLine("***************************  Perfect matching tests  ***************************");
            matchingTests.PreformTests(true, false);
        }
Example #9
0
        static void Main()
        {
            TestSet finalVelocitiesTests = new TestSet();

            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, new int[] { 0 }, 0, 0));
            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, new int[] { 10 }, 10, 10));
            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, new int[] { 10, 3, 5, 4 }, 2, 22));
            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, new int[] { 4, 11, 5, 5, 5 }, 0, 30));
            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, new int[] { 10, 10, 5, 3, 1 }, 1, 29));
            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, new int[] { 10, 10, 5, 3, 1, 9, 24, 3, 4, 19, 18, 7, 7, 8, 10, 5 }, 1, 143));
            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, new int[] { 7, 10, 2, 18, 4, 6, 6 }, 1, 53));
            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, GenerateTestArray(20, 1024), 1, 1101));
            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, GenerateTestArray(100, 1024), 0, 4650));
            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, GenerateTestArray(100, 123424), 1, 5337));
            finalVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.FinalVelocities, GenerateTestArray(1000, 123424), 1, 49209));

            Console.WriteLine("\nFinal velocities tests");
            finalVelocitiesTests.PreformTests(verbose: true, checkTimeLimit: false);


            TestSet journeyVelocitiesTests = new TestSet();

            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, new int[] { 10 }, 10, 10, true));
            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, new int[] { 10, 1, 1, 1 }, 7, 13, true));
            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, new int[] { 10, 3, 5, 4 }, 2, 22, true));
            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, new int[] { 4, 11, 5, 5, 5 }, 0, 30, true));
            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, new int[] { 10, 10, 5, 3, 1 }, 0, 29, true));
            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, new int[] { 5, 5, 10, 23, 45, 2, 1, 23, 9, 0, 8, 4, 1, 24, 86, 5, 6, 100, 353, 4, 5, 67, 32, 45, 23, 34, 56, 32, 23 }, 0, 1031, true));
            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, GenerateTestArray(20, 1024), 0, 1101, true));
            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, GenerateTestArray(100, 1024), 0, 4650, true));
            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, GenerateTestArray(100, 123424), 0, 5337, true));
            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, GenerateTestArray(1000, 123424), 0, 49209, true));
            int[] x = { 2, 2 }, y = GenerateTestArray(1000, 123424), z = new int[x.Length + y.Length];
            x.CopyTo(z, 0);
            y.CopyTo(z, x.Length);
            journeyVelocitiesTests.TestCases.Add(new VelocityMeasurementsTestCase(5, VelocityMeasurements.JourneyVelocities, z, 0, 49213, true));



            Console.WriteLine("\nJourney velocities tests");
            journeyVelocitiesTests.PreformTests(verbose: true, checkTimeLimit: false);

            //Custom Tests by G.Rozdzialik:
            Console.WriteLine("Custom tests");

            int[] testMeasurementsCounts = new int[] { 5, 100, 150, 200, 300, 400, 500, 1500, 4000 };
            int[] seeds = new int[] { 123456, 1000, 123456, 123456, 123456, 123456, 123456, 123456, 123456 };

            Stopwatch stopwatch = new Stopwatch();

            for (int i = 0; i < testMeasurementsCounts.Length; i++)
            {
                int[]  measurements = GenerateTestArray(testMeasurementsCounts[i], seeds[i]);
                bool[] isBrakingValue;

                stopwatch.Restart();
                Velocities velocities = VelocityMeasurements.FinalVelocities(measurements, out isBrakingValue);
                stopwatch.Stop();

                Console.WriteLine("Custom test {0,-1}:", i + 1, velocities.minVelocity, velocities.maxVelocity);
                Console.WriteLine("  min = {0}", velocities.minVelocity);
                Console.WriteLine("  max = {0}", velocities.maxVelocity);

                VelocityMeasurementsTestCase testCase = new VelocityMeasurementsTestCase(2, VelocityMeasurements.FinalVelocities,
                                                                                         measurements, velocities.minVelocity, velocities.maxVelocity);

                if (testCase.CustomIsBrakingArrayCorrect(isBrakingValue))
                {
                    Console.WriteLine("  isBrakingValue correct");
                }
                else
                {
                    Console.WriteLine("  isBrakingValue INVALID");
                }
                Console.WriteLine("  time elapsed = {0,5} ms", stopwatch.ElapsedMilliseconds);
                Console.WriteLine(String.Empty);
            }
            //------------------------------------------------------------------------
        }
Example #10
0
        static void Main()
        {
            bool isExtraTests           = true;
            bool runCustomTests         = true;
            bool runLargeCustomTests    = true;
            bool runExtremelyLargeTests = true;

            Console.WriteLine("Running boilerplate task");
            long boilerplateTaskTimeElapsed = PerformBoilerplateTask();

            Console.WriteLine("Boilerplate task done\n");

            TestSet set = new TestSet();

            set.TestCases.Add(new BridgeCrossingTestCase(5, new int[] { 1, 2, 5, 10 }, 17));
            set.TestCases.Add(new BridgeCrossingTestCase(5, new int[] { 15, 10, 6, 7 }, 42));
            set.TestCases.Add(new BridgeCrossingTestCase(5, new int[] { 10, 25, 20, 5 }, 60));
            set.TestCases.Add(new BridgeCrossingTestCase(5, new int[] { 100 }, 100));
            set.TestCases.Add(new BridgeCrossingTestCase(5, new int[] { 1, 20 }, 20));
            set.TestCases.Add(new BridgeCrossingTestCase(5, new int[] { 1, 10, 100 }, 111));
            set.TestCases.Add(new BridgeCrossingTestCase(5, new int[] { 2, 2, 2, 2, 2 }, 14));
            set.TestCases.Add(new BridgeCrossingTestCase(5, new int[] { 1, 2, 3, 4, 5 }, 16));
            set.TestCases.Add(new BridgeCrossingTestCase(5, new int[] { 1, 1, 5, 5, 10, 10 }, 22));
            set.TestCases.Add(new BridgeCrossingTestCase(5, GenerateTestArray(5, 555), 284));
            set.TestCases.Add(new BridgeCrossingTestCase(5, GenerateTestArray(6, 666), 346));
            set.TestCases.Add(new BridgeCrossingTestCase(5, GenerateTestArray(7, 777), 216));
            Console.WriteLine("\nBasic tests");

            long[] elapsedTime = new long[5];
            var    stopwatch   = System.Diagnostics.Stopwatch.StartNew();

            set.PreformTests(verbose: true, checkTimeLimit: false);
            stopwatch.Stop();
            elapsedTime[0] = stopwatch.ElapsedMilliseconds;


            if (isExtraTests)
            {
                TestSet set2 = new TestSet();
                set2.TestCases.Add(new BridgeCrossingTestCase(3, GenerateTestArray(8, 888), 313));
                set2.TestCases.Add(new BridgeCrossingTestCase(30, GenerateTestArray(9, 999), 453));
                Console.WriteLine("\nExtra tests");

                stopwatch.Restart();
                set2.PreformTests(verbose: true, checkTimeLimit: true);
                stopwatch.Stop();
                elapsedTime[1] = stopwatch.ElapsedMilliseconds;
            }

            if (runCustomTests)
            {
                TestSet set3 = new TestSet();
                set3.TestCases.Add(new BridgeCrossingTestCase(3, GenerateTestArray(8, 123), 283));
                set3.TestCases.Add(new BridgeCrossingTestCase(30, GenerateTestArray(9, 1234), 641));
                set3.TestCases.Add(new BridgeCrossingTestCase(30, GenerateTestArray(9, 5678), 305));
                set3.TestCases.Add(new BridgeCrossingTestCase(30, GenerateTestArray(9, 9012), 335));
                set3.TestCases.Add(new BridgeCrossingTestCase(30, GenerateTestArray(9, 3456), 452));
                set3.TestCases.Add(new BridgeCrossingTestCase(30, GenerateTestArray(9, 7890), 364));
                Console.WriteLine("\nCustom tests");

                stopwatch.Restart();
                set3.PreformTests(verbose: true, checkTimeLimit: false);
                stopwatch.Stop();
                elapsedTime[2] = stopwatch.ElapsedMilliseconds;
            }

            if (runLargeCustomTests)
            {
                TestSet set4 = new TestSet();
                set4.TestCases.Add(new BridgeCrossingTestCase(300, GenerateTestArray(10, 2703), 249));
                set4.TestCases.Add(new BridgeCrossingTestCase(300, GenerateTestArray(10, 6969), 245));
                set4.TestCases.Add(new BridgeCrossingTestCase(300, GenerateTestArray(10, 1), 379));
                Console.WriteLine("\nCustom large tests");

                stopwatch.Restart();
                set4.PreformTests(verbose: true, checkTimeLimit: false);
                stopwatch.Stop();
                elapsedTime[3] = stopwatch.ElapsedMilliseconds;
            }

            if (runExtremelyLargeTests)
            {
                TestSet set5 = new TestSet();
                set5.TestCases.Add(new BridgeCrossingTestCase(300, GenerateTestArray(150, 1), 3678));
                set5.TestCases.Add(new BridgeCrossingTestCase(300, GenerateTestArray(250, 2), 6268));
                set5.TestCases.Add(new BridgeCrossingTestCase(300, GenerateTestArray(300, 3), 7537));
                set5.TestCases.Add(new BridgeCrossingTestCase(300, GenerateTestArray(400, 4), 10169));
                set5.TestCases.Add(new BridgeCrossingTestCase(300, GenerateTestArray(400, 5), 9862));
                set5.TestCases.Add(new BridgeCrossingTestCase(300, GenerateTestArray(500, 6), 12615));
                set5.TestCases.Add(new BridgeCrossingTestCase(300, GenerateTestArray(600, 7), 14124));
                set5.TestCases.Add(new BridgeCrossingTestCase(300, GenerateTestArray(1500, 8), 36810));
                set5.TestCases.Add(new BridgeCrossingTestCase(300, GenerateTestArray(3000, 9), 73827));
                set5.TestCases.Add(new BridgeCrossingTestCase(300, GenerateTestArray(100000, 10), 2478340));
                Console.WriteLine("\nCustom extremely large tests");

                stopwatch.Restart();
                set5.PreformTests(verbose: true, checkTimeLimit: false);
                stopwatch.Stop();
                elapsedTime[4] = stopwatch.ElapsedMilliseconds;
            }

            Console.WriteLine("Basic tests   : {0,5} ms          ({1:F3} times the boilerplate time)", elapsedTime[0], (double)elapsedTime[0] / boilerplateTaskTimeElapsed);
            Console.WriteLine("Extra tests   : {0,5} ms          ({1:F3} times the boilerplate time)", elapsedTime[1], (double)elapsedTime[1] / boilerplateTaskTimeElapsed);
            if (runCustomTests)
            {
                Console.WriteLine("Custom tests  : {0,5} ms          ({1:F3} times the boilerplate time)", elapsedTime[2], (double)elapsedTime[2] / boilerplateTaskTimeElapsed);
            }
            if (runLargeCustomTests)
            {
                Console.WriteLine("Large custom  : {0,5} ms          ({1:F3} times the boilerplate time)", elapsedTime[3], (double)elapsedTime[3] / boilerplateTaskTimeElapsed);
            }
            if (runExtremelyLargeTests)
            {
                Console.WriteLine("Extreme custom: {0,5} ms          ({1:F3} times the boilerplate time)", elapsedTime[4], (double)elapsedTime[4] / boilerplateTaskTimeElapsed);
            }
        }
Example #11
0
        public static void Main()
        {
            // Przyklady testowe dla SimpleList

            TestSet simpleListAdd = new TestSet();

            simpleListAdd.TestCases.Add(new ListTestCase(5, null, new SimpleList(), new ListTestCaseParams[] {
                new ListTestCaseParams('a', 10, true, new int[] { 10 }),
                new ListTestCaseParams('a', 10, false, new int[] { 10 }),
                new ListTestCaseParams('a', 5, true, new int[] { 10, 5 }),
                new ListTestCaseParams('a', 10, false, new int[] { 10, 5 }),
                new ListTestCaseParams('a', 5, false, new int[] { 10, 5 }),
                new ListTestCaseParams('a', 15, true, new int[] { 10, 5, 15 }),
                new ListTestCaseParams('a', 5, false, new int[] { 10, 5, 15 }),
                new ListTestCaseParams('a', 15, false, new int[] { 10, 5, 15 }),
                new ListTestCaseParams('a', 10, false, new int[] { 10, 5, 15 }),
                new ListTestCaseParams('a', 20, true, new int[] { 10, 5, 15, 20 }),
            }));

            TestSet simpleListAddSearch = new TestSet();

            simpleListAddSearch.TestCases.Add(new ListTestCase(5, null, new SimpleList(), new ListTestCaseParams[] {
                new ListTestCaseParams('s', 10, false, new int[] { }),
                new ListTestCaseParams('a', 10, true, new int[] { 10 }),
                new ListTestCaseParams('s', 10, true, new int[] { 10 }),
                new ListTestCaseParams('s', 20, false, new int[] { 10 }),
                new ListTestCaseParams('a', 10, false, new int[] { 10 }),
                new ListTestCaseParams('a', 5, true, new int[] { 10, 5 }),
                new ListTestCaseParams('s', 5, true, new int[] { 10, 5 }),
                new ListTestCaseParams('s', 20, false, new int[] { 10, 5 }),
                new ListTestCaseParams('a', 10, false, new int[] { 10, 5 }),
                new ListTestCaseParams('a', 5, false, new int[] { 10, 5 }),
                new ListTestCaseParams('a', 15, true, new int[] { 10, 5, 15 }),
                new ListTestCaseParams('s', 15, true, new int[] { 10, 5, 15 }),
                new ListTestCaseParams('s', 20, false, new int[] { 10, 5, 15 }),
                new ListTestCaseParams('a', 5, false, new int[] { 10, 5, 15 }),
                new ListTestCaseParams('a', 15, false, new int[] { 10, 5, 15 }),
                new ListTestCaseParams('a', 10, false, new int[] { 10, 5, 15 }),
                new ListTestCaseParams('a', 20, true, new int[] { 10, 5, 15, 20 }),
                new ListTestCaseParams('s', 20, true, new int[] { 10, 5, 15, 20 }),
            }));

            TestSet    simpleListAddRemove = new TestSet();
            SimpleList list = new SimpleList();

            simpleListAddRemove.TestCases.Add(new ListTestCase(5, null, list, new ListTestCaseParams[] {
                new ListTestCaseParams('r', 10, false, new int[] { }),
                new ListTestCaseParams('a', 10, true, new int[] { 10 }),
                new ListTestCaseParams('r', 15, false, new int[] { 10 }),
                new ListTestCaseParams('a', 20, true, new int[] { 10, 20 }),
                new ListTestCaseParams('r', 15, false, new int[] { 10, 20 }),
                new ListTestCaseParams('r', 10, true, new int[] { 20 }),
                new ListTestCaseParams('a', 15, true, new int[] { 20, 15 }),
                new ListTestCaseParams('a', 25, true, new int[] { 20, 15, 25 }),
                new ListTestCaseParams('r', 15, true, new int[] { 20, 25 }),
                new ListTestCaseParams('a', 30, true, new int[] { 20, 25, 30 }),
                new ListTestCaseParams('r', 40, false, new int[] { 20, 25, 30 }),
                new ListTestCaseParams('r', 30, true, new int[] { 20, 25 }),
                new ListTestCaseParams('a', 15, true, new int[] { 20, 25, 15 }),
                new ListTestCaseParams('r', 25, true, new int[] { 20, 15 }),
                new ListTestCaseParams('r', 15, true, new int[] { 20 }),
                new ListTestCaseParams('a', 10, true, new int[] { 20, 10 }),
                new ListTestCaseParams('r', 20, true, new int[] { 10 }),
                new ListTestCaseParams('r', 10, true, new int[] { }),
                new ListTestCaseParams('a', 15, true, new int[] { 15 }),
            }));

            TestSet simpleListAddSearchRemove = new TestSet();

            simpleListAddSearchRemove.TestCases.Add(new ListTestCase(5, null, new SimpleList(), new ListTestCaseParams[] {
                new ListTestCaseParams('r', 10, false, new int[] { }),
                new ListTestCaseParams('s', 10, false, new int[] { }),
                new ListTestCaseParams('a', 10, true, new int[] { 10 }),
                new ListTestCaseParams('r', 15, false, new int[] { 10 }),
                new ListTestCaseParams('a', 20, true, new int[] { 10, 20 }),
                new ListTestCaseParams('s', 20, true, new int[] { 10, 20 }),
                new ListTestCaseParams('r', 15, false, new int[] { 10, 20 }),
                new ListTestCaseParams('r', 10, true, new int[] { 20 }),
                new ListTestCaseParams('a', 15, true, new int[] { 20, 15 }),
                new ListTestCaseParams('s', 20, true, new int[] { 20, 15 }),
                new ListTestCaseParams('a', 25, true, new int[] { 20, 15, 25 }),
                new ListTestCaseParams('r', 15, true, new int[] { 20, 25 }),
                new ListTestCaseParams('a', 30, true, new int[] { 20, 25, 30 }),
                new ListTestCaseParams('r', 40, false, new int[] { 20, 25, 30 }),
                new ListTestCaseParams('s', 15, false, new int[] { 20, 25, 30 }),
                new ListTestCaseParams('r', 30, true, new int[] { 20, 25 }),
                new ListTestCaseParams('r', 25, true, new int[] { 20 }),
                new ListTestCaseParams('r', 20, true, new int[] { }),
            }));

            // Przyklady testowe dla MoveToFrontList

            TestSet moveToFrontListAdd = new TestSet();

            moveToFrontListAdd.TestCases.Add(new ListTestCase(5, null, new MoveToFrontList(), new ListTestCaseParams[] {
                new ListTestCaseParams('a', 10, true, new int[] { 10 }),
                new ListTestCaseParams('a', 10, false, new int[] { 10 }),
                new ListTestCaseParams('a', 15, true, new int[] { 15, 10 }),
                new ListTestCaseParams('a', 10, false, new int[] { 10, 15 }),
                new ListTestCaseParams('a', 15, false, new int[] { 15, 10 }),
                new ListTestCaseParams('a', 25, true, new int[] { 25, 15, 10 }),
                new ListTestCaseParams('a', 15, false, new int[] { 15, 25, 10 }),
                new ListTestCaseParams('a', 10, false, new int[] { 10, 15, 25 }),
                new ListTestCaseParams('a', 20, true, new int[] { 20, 10, 15, 25 }),
            }));

            TestSet moveToFrontListAddSearch = new TestSet();

            moveToFrontListAddSearch.TestCases.Add(new ListTestCase(5, null, new MoveToFrontList(), new ListTestCaseParams[] {
                new ListTestCaseParams('s', 10, false, new int[] { }),
                new ListTestCaseParams('a', 10, true, new int[] { 10 }),
                new ListTestCaseParams('s', 10, true, new int[] { 10 }),
                new ListTestCaseParams('s', 20, false, new int[] { 10 }),
                new ListTestCaseParams('a', 10, false, new int[] { 10 }),
                new ListTestCaseParams('a', 15, true, new int[] { 15, 10 }),
                new ListTestCaseParams('s', 15, true, new int[] { 15, 10 }),
                new ListTestCaseParams('s', 20, false, new int[] { 15, 10 }),
                new ListTestCaseParams('a', 10, false, new int[] { 10, 15 }),
                new ListTestCaseParams('a', 15, false, new int[] { 15, 10 }),
                new ListTestCaseParams('a', 25, true, new int[] { 25, 15, 10 }),
                new ListTestCaseParams('s', 25, true, new int[] { 25, 15, 10 }),
                new ListTestCaseParams('s', 20, false, new int[] { 25, 15, 10 }),
                new ListTestCaseParams('a', 15, false, new int[] { 15, 25, 10 }),
                new ListTestCaseParams('a', 25, false, new int[] { 25, 15, 10 }),
                new ListTestCaseParams('a', 10, false, new int[] { 10, 25, 15 }),
                new ListTestCaseParams('a', 20, true, new int[] { 20, 10, 25, 15 }),
                new ListTestCaseParams('s', 25, true, new int[] { 25, 20, 10, 15 }),
            }));

            TestSet moveToFrontListAddRemove = new TestSet();

            moveToFrontListAddRemove.TestCases.Add(new ListTestCase(5, null, new MoveToFrontList(), new ListTestCaseParams[] {
                new ListTestCaseParams('r', 10, false, new int[] { }),
                new ListTestCaseParams('a', 10, true, new int[] { 10 }),
                new ListTestCaseParams('r', 15, false, new int[] { 10 }),
                new ListTestCaseParams('a', 20, true, new int[] { 20, 10 }),
                new ListTestCaseParams('r', 15, false, new int[] { 20, 10 }),
                new ListTestCaseParams('r', 10, true, new int[] { 20 }),
                new ListTestCaseParams('a', 15, true, new int[] { 15, 20 }),
                new ListTestCaseParams('a', 25, true, new int[] { 25, 15, 20 }),
                new ListTestCaseParams('r', 15, true, new int[] { 25, 20 }),
                new ListTestCaseParams('a', 30, true, new int[] { 30, 25, 20 }),
                new ListTestCaseParams('r', 40, false, new int[] { 30, 25, 20 }),
                new ListTestCaseParams('r', 30, true, new int[] { 25, 20 }),
                new ListTestCaseParams('r', 25, true, new int[] { 20 }),
                new ListTestCaseParams('r', 20, true, new int[] { }),
            }));

            TestSet moveToFrontListAddSearchRemove = new TestSet();

            moveToFrontListAddSearchRemove.TestCases.Add(new ListTestCase(5, null, new MoveToFrontList(), new ListTestCaseParams[] {
                new ListTestCaseParams('r', 10, false, new int[] { }),
                new ListTestCaseParams('s', 10, false, new int[] { }),
                new ListTestCaseParams('a', 10, true, new int[] { 10 }),
                new ListTestCaseParams('r', 15, false, new int[] { 10 }),
                new ListTestCaseParams('a', 20, true, new int[] { 20, 10 }),
                new ListTestCaseParams('s', 10, true, new int[] { 10, 20 }),
                new ListTestCaseParams('r', 15, false, new int[] { 10, 20 }),
                new ListTestCaseParams('r', 10, true, new int[] { 20 }),
                new ListTestCaseParams('a', 15, true, new int[] { 15, 20 }),
                new ListTestCaseParams('s', 20, true, new int[] { 20, 15 }),
                new ListTestCaseParams('a', 25, true, new int[] { 25, 20, 15 }),
                new ListTestCaseParams('r', 15, true, new int[] { 25, 20 }),
                new ListTestCaseParams('a', 30, true, new int[] { 30, 25, 20 }),
                new ListTestCaseParams('r', 40, false, new int[] { 30, 25, 20 }),
                new ListTestCaseParams('s', 15, false, new int[] { 30, 25, 20 }),
                new ListTestCaseParams('r', 25, true, new int[] { 30, 20 }),
                new ListTestCaseParams('r', 20, true, new int[] { 30 }),
                new ListTestCaseParams('r', 30, true, new int[] { }),
            }));

            // Testy dla SimpleList

            Console.WriteLine("\n*** Test 1.1");
            Console.WriteLine("SimpleList - Add");
            simpleListAdd.PreformTests(verbose: true, checkTimeLimit: false);

            Console.WriteLine("\n*** Test 1.2");
            Console.WriteLine("SimpleList - Add,Search");
            simpleListAddSearch.PreformTests(verbose: true, checkTimeLimit: false);

            Console.WriteLine("\n*** Test 1.3");
            Console.WriteLine("SimpleList - Add,Remove");
            simpleListAddRemove.PreformTests(verbose: true, checkTimeLimit: false);

            Console.WriteLine("\n*** Test 1.4");
            Console.WriteLine("SimpleList - Add,Search,Remove");
            simpleListAddSearchRemove.PreformTests(verbose: true, checkTimeLimit: false);

            // Testy dla MoveToFrontList

            Console.WriteLine("\n*** Test 2.1");
            Console.WriteLine("MoveToFrontList - Add");
            moveToFrontListAdd.PreformTests(verbose: true, checkTimeLimit: false);

            Console.WriteLine("\n*** Test 2.2");
            Console.WriteLine("MoveToFrontList - Add,Search");
            moveToFrontListAddSearch.PreformTests(verbose: true, checkTimeLimit: false);

            Console.WriteLine("\n*** Test 2.3");
            Console.WriteLine("MoveToFrontList - Add,Remove");
            moveToFrontListAddRemove.PreformTests(verbose: true, checkTimeLimit: false);

            Console.WriteLine("\n*** Test 2.4");
            Console.WriteLine("MoveToFrontList - Add,Search,Remove");
            moveToFrontListAddSearchRemove.PreformTests(verbose: true, checkTimeLimit: false);
        }
Example #12
0
        static void Main(string[] args)
        {
            TestSet cyclePartitionTests = new TestSet();
            TestSet matchingTests       = new TestSet();

            Graph C4 = new AdjacencyMatrixGraph(false, 4);

            C4.AddEdge(0, 1);
            C4.AddEdge(0, 3);
            C4.AddEdge(2, 1);
            C4.AddEdge(2, 3);
            cyclePartitionTests.TestCases.Add(new CyclePartitionTestCase(5, null, C4));
            matchingTests.TestCases.Add(new PerfectMatchingTestCase(5, null, C4));

            Graph DoubleC4 = new AdjacencyMatrixGraph(false, 8);

            DoubleC4.AddEdge(0, 1);
            DoubleC4.AddEdge(0, 3);
            DoubleC4.AddEdge(2, 1);
            DoubleC4.AddEdge(2, 3);

            DoubleC4.AddEdge(4, 5);
            DoubleC4.AddEdge(4, 7);
            DoubleC4.AddEdge(6, 5);
            DoubleC4.AddEdge(6, 7);

            cyclePartitionTests.TestCases.Add(new CyclePartitionTestCase(5, null, DoubleC4));
            matchingTests.TestCases.Add(new PerfectMatchingTestCase(5, null, DoubleC4));

            Graph matching = new AdjacencyListsGraph <SimpleAdjacencyList>(false, 20);

            for (int i = 0; i < 10; i++)
            {
                matching.AddEdge((3 * i) % 20, (3 * i + 10) % 20);
            }

            matchingTests.TestCases.Add(new PerfectMatchingTestCase(5, null, matching));

            Graph tripleC6 = new AdjacencyListsGraph <HashTableAdjacencyList>(false, 18);

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 6; j++)
                {
                    tripleC6.AddEdge(6 * i + j, 6 * i + (j + 1) % 6);
                }
            }

            cyclePartitionTests.TestCases.Add(new CyclePartitionTestCase(5, null, tripleC6));
            matchingTests.TestCases.Add(new PerfectMatchingTestCase(5, null, tripleC6));

            Graph C4free = new AdjacencyListsGraph <HashTableAdjacencyList>(false, 54);

            for (int c = 0; c < 3; c++)
            {
                for (int i = 0; i < 3; i++)
                {
                    for (int j = 0; j < 6; j++)
                    {
                        C4free.AddEdge(18 * c + 6 * i + j, 18 * c + 6 * i + (j + 1) % 6);
                    }
                }
            }
            for (int c = 0; c < 3; c++)
            {
                for (int i = 0; i < 3; i++)
                {
                    for (int j = 0; j < 6; j += 2)
                    {
                        C4free.AddEdge(18 * c + 6 * i + j, 18 * c + 6 * ((i + 1) % 3) + (j + 1) % 6);
                    }
                }
            }
            for (int c = 0; c < 3; c++)
            {
                for (int i = 0; i < 3; i++)
                {
                    for (int j = 0; j < 6; j += 2)
                    {
                        C4free.AddEdge(18 * c + 6 * i + j, 18 * ((c + 1) % 3) + 6 * ((i + 1) % 3) + (j + 1) % 6);
                    }
                }
            }

            cyclePartitionTests.TestCases.Add(new CyclePartitionTestCase(5, null, C4free));
            matchingTests.TestCases.Add(new PerfectMatchingTestCase(5, null, C4free));

            cyclePartitionTests.TestCases.Add(new CyclePartitionTestCase(5, null, randomRegularBipartite(100, 10, 13)));
            cyclePartitionTests.TestCases.Add(new CyclePartitionTestCase(5, null, randomRegularBipartite(100, 40, 14)));
            cyclePartitionTests.TestCases.Add(new CyclePartitionTestCase(5, null, randomRegularBipartite(200, 8, 15)));
            cyclePartitionTests.TestCases.Add(new CyclePartitionTestCase(5, null, randomRegularBipartite(100, 16, 16)));


            matchingTests.TestCases.Add(new PerfectMatchingTestCase(5, null, randomRegularBipartite(300, 4, 13)));
            matchingTests.TestCases.Add(new PerfectMatchingTestCase(5, null, randomRegularBipartite(200, 8, 14)));
            matchingTests.TestCases.Add(new PerfectMatchingTestCase(5, null, randomRegularBipartite(200, 16, 15)));
            matchingTests.TestCases.Add(new PerfectMatchingTestCase(5, null, randomRegularBipartite(100, 32, 16)));

            Console.WriteLine("***************************   Cycle partition tests  ***************************");
            cyclePartitionTests.PreformTests(true, false);

            Console.WriteLine("***************************  Perfect matching tests  ***************************");
            matchingTests.PreformTests(true, false);



            Console.WriteLine("**************************   Custom tests *************************");
            Console.WriteLine("Timing a boilerplate task");
            long boilerplateTaskTimeElapsed = PerformBoilerplateTask();

            Console.WriteLine("Boilerplate task done. Results will be shown below");



            int     baseSeed             = 15; // will be incremented for every test
            int     customTestSetSize    = 15;
            TestSet customPartitionTests = new TestSet();
            TestSet customMatchingTests  = new TestSet();

            Console.WriteLine("Generating test cases, this may take a while");
            for (int i = 0; i < customTestSetSize; i++)
            {
                Random r        = new Random(baseSeed);
                int    vertices = r.Next(100, 400);
                int    degree   = 2 * r.Next(2, 40);
                customPartitionTests.TestCases.Add(new CyclePartitionTestCase(5, null, randomRegularBipartite(vertices, degree, baseSeed++)));
            }

            for (int i = 0; i < customTestSetSize; i++)
            {
                Random r        = new Random(baseSeed);
                int    vertices = r.Next(100, 400);
                int    degree   = (int)Math.Pow(2, r.Next(2, 7));
                customMatchingTests.TestCases.Add(new PerfectMatchingTestCase(5, null, randomRegularBipartite(vertices, degree, baseSeed++)));
            }

            var stopwatch = System.Diagnostics.Stopwatch.StartNew();

            // Preform tests... (Why do they have a typo in the test library? Even after a month)
            customPartitionTests.PreformTests(true, false);
            stopwatch.Stop();

            long partitionTestsTimeElapsed = stopwatch.ElapsedMilliseconds;

            stopwatch.Restart();
            customMatchingTests.PreformTests(true, false);
            stopwatch.Stop();
            long matchingTestsTimeElapsed = stopwatch.ElapsedMilliseconds;

            Console.WriteLine("Custom tests performance metrics");
            Console.WriteLine("Boilerplate task: {0,5} ms", boilerplateTaskTimeElapsed);
            Console.WriteLine("Partition tests: {0,5} ms        ({1:F3} times the boilerplate time)", partitionTestsTimeElapsed, (double)partitionTestsTimeElapsed / boilerplateTaskTimeElapsed);
            Console.WriteLine("Matching tests:  {0,5} ms        ({1:F3} times the boilerplate time)", matchingTestsTimeElapsed, (double)matchingTestsTimeElapsed / boilerplateTaskTimeElapsed);
        }
Example #13
0
        static void Main()
        {
            bool drawBitmaps = false;

            TestSet isSameSideTests = new TestSet();

            isSameSideTests.TestCases.Add(new IsSameSideTestCase(5, new Point(0, 1), new Point(2, 1), new Segment(new Point(1, 1), new Point(4, 4)), false));
            isSameSideTests.TestCases.Add(new IsSameSideTestCase(5, new Point(2, 1), new Point(0, 1), new Segment(new Point(1, 1), new Point(4, 4)), false));
            isSameSideTests.TestCases.Add(new IsSameSideTestCase(5, new Point(1, 3), new Point(2, 6), new Segment(new Point(1, 1), new Point(4, 4)), true));
            isSameSideTests.TestCases.Add(new IsSameSideTestCase(5, new Point(2, 6), new Point(1, 3), new Segment(new Point(1, 1), new Point(4, 4)), true));
            isSameSideTests.TestCases.Add(new IsSameSideTestCase(5, new Point(2, 2), new Point(3, 3), new Segment(new Point(1, 1), new Point(4, 4)), true));
            isSameSideTests.TestCases.Add(new IsSameSideTestCase(5, new Point(2, 2), new Point(-1, -1), new Segment(new Point(1, 1), new Point(4, 4)), true));
            isSameSideTests.TestCases.Add(new IsSameSideTestCase(5, new Point(2, 2), new Point(5, 3), new Segment(new Point(1, 1), new Point(4, 4)), true));
            isSameSideTests.TestCases.Add(new IsSameSideTestCase(5, new Point(2, 2), new Point(1, 3), new Segment(new Point(1, 1), new Point(4, 4)), true));
            isSameSideTests.TestCases.Add(new IsSameSideTestCase(5, new Point(2, 2), new Point(1, 3), new Segment(new Point(-5, -2), new Point(-1, -4)), true));
            isSameSideTests.TestCases.Add(new IsSameSideTestCase(5, new Point(0, 0), new Point(1, 1), new Segment(new Point(-5, -2), new Point(-1, -4)), true));
            isSameSideTests.TestCases.Add(new IsSameSideTestCase(5, new Point(0, 0), new Point(-3, -4), new Segment(new Point(-5, -2), new Point(-1, -4)), false));
            isSameSideTests.TestCases.Add(new IsSameSideTestCase(5, new Point(0, 0), new Point(-10, 0), new Segment(new Point(-5, -2), new Point(-1, -4)), false));
            isSameSideTests.TestCases.Add(new IsSameSideTestCase(5, new Point(2, 3), new Point(-3, 4), new Segment(new Point(-5, 5), new Point(0, 0)), true));
            isSameSideTests.TestCases.Add(new IsSameSideTestCase(5, new Point(-4, 1), new Point(-1, 4), new Segment(new Point(-5, 5), new Point(0, 0)), false));

            TestSet polygonAreaTests = new TestSet();

            polygonAreaTests.TestCases.Add(new PolygonAreaTestCase(5, new Point[] { new Point(0, 0) }, 0));
            polygonAreaTests.TestCases.Add(new PolygonAreaTestCase(5, new Point[] { new Point(1, 1), new Point(2, 2) }, 0));
            polygonAreaTests.TestCases.Add(new PolygonAreaTestCase(5, new Point[] { new Point(1, 1), new Point(2, 2), new Point(2, 0) }, 1));
            polygonAreaTests.TestCases.Add(new PolygonAreaTestCase(5, new Point[] { new Point(-1, -1), new Point(2, -1), new Point(2, 3),
                                                                                    new Point(-1, 3) }, 12));
            polygonAreaTests.TestCases.Add(new PolygonAreaTestCase(5, new Point[] { new Point(3, 4), new Point(5, 11), new Point(12, 8),
                                                                                    new Point(9, 5), new Point(5, 6) }, 30));
            polygonAreaTests.TestCases.Add(new PolygonAreaTestCase(5, new Point[] { new Point(-5, 0), new Point(-3, 0), new Point(-2, -1),
                                                                                    new Point(0, -1), new Point(0, 3), new Point(-2, 1), new Point(-3, 2) }, 10));
            polygonAreaTests.TestCases.Add(new PolygonAreaTestCase(5, new Point[] { new Point(-3, -2), new Point(-4, -4), new Point(-2, -3), new Point(0, -3),
                                                                                    new Point(0, -5), new Point(5, 0), new Point(0, 0), new Point(0, 2), new Point(-1, 2), new Point(-1, 1), new Point(-6, 1) }, 31));
            polygonAreaTests.TestCases.Add(new PolygonAreaTestCase(5, GenerateRandomPolygon(12, 111), 120.5));
            polygonAreaTests.TestCases.Add(new PolygonAreaTestCase(5, GenerateRandomPolygon(16, 222), 172));
            polygonAreaTests.TestCases.Add(new PolygonAreaTestCase(5, GenerateRandomPolygon(20, 111), 139));

            TestSet sutherlandHodgmanTests = new TestSet();

            Point[] sp1 = new Point[] { new Point(2, 1), new Point(4, 1), new Point(4, 3), new Point(2, 3) };
            Point[] cp1 = new Point[] { new Point(3, 2), new Point(5, 2), new Point(5, 4), new Point(3, 4) };
            Point[] sh1 = new Point[] { new Point(3, 2), new Point(4, 2), new Point(4, 3), new Point(3, 3) };
            sutherlandHodgmanTests.TestCases.Add(new SutherlandHodgmanTestCase(5, sp1, cp1, sh1));

            Point[] sp2 = new Point[] { new Point(2, 1), new Point(4, 1), new Point(4, 3), new Point(2, 3) };
            Point[] cp2 = new Point[] { new Point(5, 2), new Point(7, 2), new Point(7, 4), new Point(5, 4) };
            Point[] sh2 = new Point[] { };
            sutherlandHodgmanTests.TestCases.Add(new SutherlandHodgmanTestCase(5, sp2, cp2, sh2));

            Point[] sp3 = new Point[] { new Point(-1, 1), new Point(0, 1), new Point(0, 2), new Point(1, 2), new Point(1, 1),
                                        new Point(2, 1), new Point(2, 3), new Point(-1, 3) };
            Point[] cp3 = new Point[] { new Point(-1, 0), new Point(2, 0), new Point(2, 2), new Point(-1, 2) };
            Point[] sh3 = new Point[] { new Point(-1, 2), new Point(-1, 1), new Point(0, 1), new Point(0, 2), new Point(1, 2),
                                        new Point(1, 1), new Point(2, 1), new Point(2, 2) };
            sutherlandHodgmanTests.TestCases.Add(new SutherlandHodgmanTestCase(5, sp3, cp3, sh3));

            Point[] sp4  = new Point[] { new Point(2, 1), new Point(4, 1), new Point(4, 3), new Point(2, 3) };
            Point[] cp4  = new Point[] { new Point(1, 0), new Point(5, 0), new Point(5, 4), new Point(1, 4) };
            Point[] sh4a = new Point[] { new Point(2, 1), new Point(4, 1), new Point(4, 3), new Point(2, 3) };
            sutherlandHodgmanTests.TestCases.Add(new SutherlandHodgmanTestCase(5, sp4, cp4, sh4a));

            Point[] sh4b = new Point[] { new Point(2, 3), new Point(2, 1), new Point(4, 1), new Point(4, 3) };
            sutherlandHodgmanTests.TestCases.Add(new SutherlandHodgmanTestCase(5, cp4, sp4, sh4b));

            Point[] sp5 = new Point[] { new Point(2, 2), new Point(3, 2), new Point(3, 4), new Point(4, 4),
                                        new Point(4, 2), new Point(5, 2), new Point(5, 5), new Point(2, 5) };
            Point[] cp5a = new Point[] { new Point(1, 3), new Point(6, 3), new Point(6, 6), new Point(1, 6) };
            Point[] sh5a = new Point[] { new Point(2, 3), new Point(3, 3), new Point(3, 4), new Point(4, 4),
                                         new Point(4, 3), new Point(5, 3), new Point(5, 5), new Point(2, 5) };
            sutherlandHodgmanTests.TestCases.Add(new SutherlandHodgmanTestCase(5, sp5, cp5a, sh5a));

            Point[] cp5b = new Point[] { new Point(1, 1), new Point(6, 1), new Point(6, 3), new Point(1, 3) };
            Point[] sh5b = new Point[] { new Point(2, 3), new Point(2, 2), new Point(3, 2), new Point(3, 3),
                                         new Point(4, 3), new Point(4, 2), new Point(5, 2), new Point(5, 3) };
            sutherlandHodgmanTests.TestCases.Add(new SutherlandHodgmanTestCase(5, sp5, cp5b, sh5b));

            Point[] sp6 = GenerateRandomPolygon(16, 222);
            Point[] cp6 = new Point[] { new Point(-9, -3), new Point(8.5, -3), new Point(8.5, 4), new Point(-9, 4) };
            Point[] sh6 = new Point[] { new Point(6.8, -3), new Point(8, 0), new Point(8.5, 0.5), new Point(8.5, 2),
                                        new Point(7.5, 4), new Point(-6, 4), new Point(-6, 2), new Point(-5, 0), new Point(-8, -2), new Point(-7.25, -3) };
            sutherlandHodgmanTests.TestCases.Add(new SutherlandHodgmanTestCase(5, sp6, cp6, sh6));

            Point[] sp7  = GenerateRandomPolygon(20, 111);
            Point[] cp7a = new Point[] { new Point(-8, -5), new Point(-6, -5), new Point(-6, 5), new Point(-8, 5) };
            Point[] sh7a = new Point[] { new Point(-6, 4), new Point(-7, 4), new Point(-6, 3), new Point(-6, -0.75),
                                         new Point(-8, -2.25), new Point(-8, -3.2), new Point(-6, -3.6) };
            sutherlandHodgmanTests.TestCases.Add(new SutherlandHodgmanTestCase(5, sp7, cp7a, sh7a));

            Point[] cp7b = new Point[] { new Point(4, -3), new Point(-4, -7), new Point(0, -7) };
            Point[] sh7b = new Point[] { new Point(4, -3), new Point(-2.8, -6.4), new Point(-2.5, -7), new Point(-1, -7),
                                         new Point(0, -6), new Point(0.5, -6.5) };
            sutherlandHodgmanTests.TestCases.Add(new SutherlandHodgmanTestCase(5, sp7, cp7b, sh7b));


            TestSet sutherlandHodgmanTestsWithDuplicates = new TestSet();

            Point[] dsp1  = new Point[] { new Point(2, 1), new Point(4, 1), new Point(4, 3), new Point(2, 3) };
            Point[] dcp1a = new Point[] { new Point(4, 1), new Point(6, 1), new Point(6, 3), new Point(4, 3) };
            Point[] dsh1a = new Point[] { new Point(4, 1), new Point(4, 3) };
            sutherlandHodgmanTestsWithDuplicates.TestCases.Add(new SutherlandHodgmanTestCase(5, dsp1, dcp1a, dsh1a));

            Point[] dcp1b = new Point[] { new Point(5, 4), new Point(3, 2), new Point(5, 0), new Point(7, 2) };
            Point[] dsh1b = new Point[] { new Point(4, 3), new Point(3, 2), new Point(4, 1) };
            sutherlandHodgmanTestsWithDuplicates.TestCases.Add(new SutherlandHodgmanTestCase(5, dsp1, dcp1b, dsh1b));

            Point[] dsp2 = new Point[] { new Point(0, 0), new Point(1, 0), new Point(1, 1), new Point(2, 1),
                                         new Point(2, 0), new Point(3, 0), new Point(3, 4), new Point(0, 4) };
            Point[] dch2 = new Point[] { new Point(0, 0), new Point(1, 0), new Point(1, 5), new Point(0, 5) };
            Point[] dsh2 = new Point[] { new Point(0, 0), new Point(1, 0), new Point(1, 1), new Point(1, 4), new Point(0, 4) };
            sutherlandHodgmanTestsWithDuplicates.TestCases.Add(new SutherlandHodgmanTestCase(5, dsp2, dch2, dsh2));

            Point[] dsp3 = GenerateRandomPolygon(14, 12345);
            Point[] dch3 = new Point[] { new Point(5, 7), new Point(-7, 5), new Point(-7, 0), new Point(5, 0) };
            Point[] dsh3 = new Point[] { new Point(5, 0), new Point(5, 6), new Point(4, 6), new Point(2.75, 6.625),
                                         new Point(-5.8, 5.2), new Point(-5, 2), new Point(-7, 2), new Point(-7, 1), new Point(-6, 0) };
            sutherlandHodgmanTestsWithDuplicates.TestCases.Add(new SutherlandHodgmanTestCase(5, dsp3, dch3, dsh3));

            Point[] dsp4 = GenerateRandomPolygon(16, 222);
            Point[] dcp4 = new Point[] { new Point(-9, -2), new Point(8, -2), new Point(8, 4), new Point(-9, 4) };
            Point[] dsh4 = new Point[] { new Point(7.2, -2), new Point(8, 0), new Point(8, 3), new Point(7.5, 4),
                                         new Point(-6, 4), new Point(-6, 2), new Point(-5, 0), new Point(-8, -2) };
            sutherlandHodgmanTestsWithDuplicates.TestCases.Add(new SutherlandHodgmanTestCase(5, dsp4, dcp4, dsh4));

            Console.WriteLine("IsSameSide tests");
            isSameSideTests.PreformTests(verbose: true, checkTimeLimit: false);

            Console.WriteLine("\nPolygon area tests");
            polygonAreaTests.PreformTests(verbose: true, checkTimeLimit: false);

            Console.WriteLine("\nSutherland-Hodgman tests");
            sutherlandHodgmanTests.PreformTests(verbose: true, checkTimeLimit: false);

            Console.WriteLine("\nSutherland-Hodgman tests with duplicates");
            sutherlandHodgmanTestsWithDuplicates.PreformTests(verbose: true, checkTimeLimit: false);

            if (drawBitmaps)
            {
                System.IO.Directory.CreateDirectory("../../Testy");
                BitmapDrawer bitmapDrawer = new BitmapDrawer(sp1, cp1, SutherlandHodgman.GetIntersectedPolygon(sp1, cp1), 1);
                bitmapDrawer = new BitmapDrawer(sp2, cp2, SutherlandHodgman.GetIntersectedPolygon(sp2, cp2), 2);
                bitmapDrawer = new BitmapDrawer(sp3, cp3, SutherlandHodgman.GetIntersectedPolygon(sp3, cp3), 3);
                bitmapDrawer = new BitmapDrawer(sp4, cp4, SutherlandHodgman.GetIntersectedPolygon(sp4, cp4), 4);
                bitmapDrawer = new BitmapDrawer(cp4, sp4, SutherlandHodgman.GetIntersectedPolygon(cp4, sp4), 5);
                bitmapDrawer = new BitmapDrawer(sp5, cp5a, SutherlandHodgman.GetIntersectedPolygon(sp5, cp5a), 6);
                bitmapDrawer = new BitmapDrawer(sp5, cp5b, SutherlandHodgman.GetIntersectedPolygon(sp5, cp5b), 7);
                bitmapDrawer = new BitmapDrawer(sp6, cp6, SutherlandHodgman.GetIntersectedPolygon(sp6, cp6), 8);
                bitmapDrawer = new BitmapDrawer(sp7, cp7a, SutherlandHodgman.GetIntersectedPolygon(sp7, cp7a), 9);
                bitmapDrawer = new BitmapDrawer(sp7, cp7b, SutherlandHodgman.GetIntersectedPolygon(sp7, cp7b), 10);
                bitmapDrawer = new BitmapDrawer(dsp1, dcp1a, SutherlandHodgman.GetIntersectedPolygon(dsp1, dcp1a), 11);
                bitmapDrawer = new BitmapDrawer(dsp1, dcp1b, SutherlandHodgman.GetIntersectedPolygon(dsp1, dcp1b), 12);
                bitmapDrawer = new BitmapDrawer(dsp2, dch2, SutherlandHodgman.GetIntersectedPolygon(dsp2, dch2), 13);
                bitmapDrawer = new BitmapDrawer(dsp3, dch3, SutherlandHodgman.GetIntersectedPolygon(dsp3, dch3), 14);
                bitmapDrawer = new BitmapDrawer(dsp4, dcp4, SutherlandHodgman.GetIntersectedPolygon(dsp4, dcp4), 15);
            }
        }
Example #14
0
        static void Main(string[] args)
        {
            GraphExport          ge  = new GraphExport();
            RandomGraphGenerator rgg = new RandomGraphGenerator();

            Graph[] directedGraphs = new Graph[8];
            directedGraphs[0] = new AdjacencyListsGraph <AVLAdjacencyList>(true, 3)
            {
                new Edge(0, 1), new Edge(1, 2), new Edge(2, 0)
            };
            directedGraphs[1] = new AdjacencyListsGraph <SimpleAdjacencyList>(true, 3)
            {
                new Edge(0, 1), new Edge(1, 2), new Edge(2, 1)
            };
            directedGraphs[2] = new AdjacencyMatrixGraph(true, 4)
            {
                new Edge(0, 1), new Edge(0, 2), new Edge(1, 3), new Edge(2, 3)
            };
            directedGraphs[3] = new AdjacencyListsGraph <HashTableAdjacencyList>(true, 10);
            directedGraphs[4] = new AdjacencyMatrixGraph(true, 10)
            {
                new Edge(0, 1), new Edge(0, 2), new Edge(0, 3), new Edge(2, 4), new Edge(2, 5), new Edge(2, 6),
                new Edge(5, 7), new Edge(5, 8), new Edge(5, 9), new Edge(6, 5), new Edge(7, 8), new Edge(8, 2)
            };
            rgg.SetSeed(111);
            directedGraphs[5] = rgg.DirectedGraph(typeof(AdjacencyMatrixGraph), 100, 0.2);
            rgg.SetSeed(222);
            directedGraphs[6] = rgg.DirectedCycle(typeof(AdjacencyListsGraph <SimpleAdjacencyList>), 1000);
            rgg.SetSeed(333);
            directedGraphs[7] = rgg.DAG(typeof(AdjacencyMatrixGraph), 200, 0.2, 1, 1);

            TestSet findCycleDirected = new TestSet();

            findCycleDirected.TestCases.Add(new FindCycleTestCase(5, null, directedGraphs[0], true));
            findCycleDirected.TestCases.Add(new FindCycleTestCase(5, null, directedGraphs[1], true));
            findCycleDirected.TestCases.Add(new FindCycleTestCase(5, null, directedGraphs[2], false));
            findCycleDirected.TestCases.Add(new FindCycleTestCase(5, null, directedGraphs[3], false));
            findCycleDirected.TestCases.Add(new FindCycleTestCase(5, null, directedGraphs[4], true));
            findCycleDirected.TestCases.Add(new FindCycleTestCase(5, null, directedGraphs[5], true));
            findCycleDirected.TestCases.Add(new FindCycleTestCase(5, null, directedGraphs[6], true));
            findCycleDirected.TestCases.Add(new FindCycleTestCase(5, null, directedGraphs[7], false));

            Graph[] undirectedGraphs = new Graph[6];
            undirectedGraphs[0] = new AdjacencyListsGraph <AVLAdjacencyList>(false, 3)
            {
                new Edge(0, 1), new Edge(1, 2), new Edge(2, 0)
            };
            undirectedGraphs[1] = new AdjacencyListsGraph <SimpleAdjacencyList>(false, 4)
            {
                new Edge(0, 1), new Edge(1, 2), new Edge(2, 3), new Edge(3, 1)
            };
            undirectedGraphs[2] = new AdjacencyListsGraph <HashTableAdjacencyList>(false, 10);
            undirectedGraphs[3] = new AdjacencyMatrixGraph(false, 10)
            {
                new Edge(0, 1), new Edge(0, 2), new Edge(0, 3), new Edge(2, 4), new Edge(2, 5), new Edge(2, 6),
                new Edge(5, 7), new Edge(5, 8), new Edge(5, 9), new Edge(8, 2)
            };
            rgg.SetSeed(444);
            undirectedGraphs[4] = rgg.UndirectedGraph(typeof(AdjacencyMatrixGraph), 100, 0.2);
            rgg.SetSeed(555);
            undirectedGraphs[5] = rgg.TreeGraph(typeof(AdjacencyListsGraph <SimpleAdjacencyList>), 1000, 1.0);

            TestSet findCycleUndirected = new TestSet();

            findCycleUndirected.TestCases.Add(new FindCycleTestCase(5, null, undirectedGraphs[0], true));
            findCycleUndirected.TestCases.Add(new FindCycleTestCase(5, null, undirectedGraphs[1], true));
            findCycleUndirected.TestCases.Add(new FindCycleTestCase(5, null, undirectedGraphs[2], false));
            findCycleUndirected.TestCases.Add(new FindCycleTestCase(5, null, undirectedGraphs[3], true));
            findCycleUndirected.TestCases.Add(new FindCycleTestCase(5, null, undirectedGraphs[4], true));
            findCycleUndirected.TestCases.Add(new FindCycleTestCase(5, null, undirectedGraphs[5], false));

            Graph[] trees = new Graph[10];
            trees[0] = new AdjacencyListsGraph <AVLAdjacencyList>(false, 3)
            {
                new Edge(0, 1), new Edge(1, 2)
            };
            trees[1] = new AdjacencyListsGraph <SimpleAdjacencyList>(false, 4)
            {
                new Edge(0, 1), new Edge(1, 2), new Edge(2, 3)
            };
            trees[2] = new AdjacencyListsGraph <HashTableAdjacencyList>(false, 1);
            trees[3] = new AdjacencyListsGraph <HashTableAdjacencyList>(false, 2)
            {
                new Edge(0, 1)
            };
            trees[4] = new AdjacencyMatrixGraph(false, 5)
            {
                new Edge(1, 3), new Edge(2, 4)
            };
            trees[5] = new AdjacencyMatrixGraph(true, 3)
            {
                new Edge(0, 1), new Edge(0, 2)
            };
            rgg.SetSeed(777);
            trees[6] = rgg.UndirectedGraph(typeof(AdjacencyMatrixGraph), 100, 0.2);
            rgg.SetSeed(888);
            trees[7] = rgg.TreeGraph(typeof(AdjacencyListsGraph <SimpleAdjacencyList>), 1000, 1.0);
            rgg.SetSeed(999);
            trees[8] = rgg.TreeGraph(typeof(AdjacencyListsGraph <SimpleAdjacencyList>), 1001, 1.0);
            trees[9] = new AdjacencyListsGraph <SimpleAdjacencyList>(false, 10);
            for (int i = 1; i < 10; ++i)
            {
                trees[9].AddEdge(i - 1, i);
            }

            TestSet treeCenter = new TestSet();

            treeCenter.TestCases.Add(new TreeCenterTestCase(5, null, trees[0], true, new int[] { 1 }));
            treeCenter.TestCases.Add(new TreeCenterTestCase(5, null, trees[1], true, new int[] { 1, 2 }));
            treeCenter.TestCases.Add(new TreeCenterTestCase(5, null, trees[2], true, new int[] { 0 }));
            treeCenter.TestCases.Add(new TreeCenterTestCase(5, null, trees[3], true, new int[] { 0, 1 }));
            treeCenter.TestCases.Add(new TreeCenterTestCase(5, null, trees[4], false, null));
            treeCenter.TestCases.Add(new TreeCenterTestCase(5, new ArgumentException(), trees[5], false, null));
            treeCenter.TestCases.Add(new TreeCenterTestCase(5, null, trees[6], false, null));
            treeCenter.TestCases.Add(new TreeCenterTestCase(5, null, trees[7], true, new int[] { 305, 786 }));
            treeCenter.TestCases.Add(new TreeCenterTestCase(5, null, trees[8], true, new int[] { 60 }));
            treeCenter.TestCases.Add(new TreeCenterTestCase(5, null, trees[9], true, new int[] { 4, 5 }));

            //
            // Odkomentuj odpowiednią linię aby zobaczyć wybrany graf
            // Pamiętaj, że przykłady numerowane są od 1
            //
            //ge.Export(directedGraphs[0]);
            //ge.Export(directedGraphs[1]);
            //ge.Export(directedGraphs[2]);
            //ge.Export(directedGraphs[3]);
            //ge.Export(directedGraphs[4]);
            //ge.Export(directedGraphs[5]);
            //ge.Export(directedGraphs[6]);
            //ge.Export(directedGraphs[7]);
            //ge.Export(undirectedGraphs[0]);
            //ge.Export(undirectedGraphs[1]);
            //ge.Export(undirectedGraphs[2]);
            ge.Export(undirectedGraphs[3]);
            //ge.Export(undirectedGraphs[4]);
            //ge.Export(undirectedGraphs[5]);
            //ge.Export(trees[0]);
            //ge.Export(trees[1]);
            //ge.Export(trees[2]);
            //ge.Export(trees[3]);
            //ge.Export(trees[4]);
            //ge.Export(trees[5]);
            //ge.Export(trees[6]);
            //ge.Export(trees[7]);
            //ge.Export(trees[8]);

            long[]    timeElapsed = new long[9];
            Stopwatch stopwatch   = new Stopwatch();


            Console.WriteLine("\nCycle Finding\n");

            FindCycleTestCase.ResultOnly = true;
            Console.WriteLine("\nDirected Graphs - result only");
            stopwatch.Start();
            findCycleDirected.PreformTests(verbose: true, checkTimeLimit: false);
            stopwatch.Stop();
            timeElapsed[0] = stopwatch.ElapsedMilliseconds;
            Console.WriteLine("\nUndirected Graphs - result only");
            stopwatch.Restart();
            findCycleUndirected.PreformTests(verbose: true, checkTimeLimit: false);
            stopwatch.Stop();
            timeElapsed[1] = stopwatch.ElapsedMilliseconds;

            FindCycleTestCase.ResultOnly = false;
            Console.WriteLine("\nDirected Graphs - full funcionality");
            stopwatch.Restart();
            findCycleDirected.PreformTests(verbose: true, checkTimeLimit: false, forceExecution: false);
            stopwatch.Stop();
            timeElapsed[2] = stopwatch.ElapsedMilliseconds;
            Console.WriteLine("\nUndirected Graphs - full funcionality");
            stopwatch.Restart();
            findCycleUndirected.PreformTests(verbose: true, checkTimeLimit: false, forceExecution: false);
            stopwatch.Stop();
            timeElapsed[3] = stopwatch.ElapsedMilliseconds;

            Console.WriteLine("\nTree Center\n");
            TreeCenterTestCase.ResultOnly = true;
            Console.WriteLine("\nResult only");
            stopwatch.Restart();
            treeCenter.PreformTests(verbose: true, checkTimeLimit: false);
            stopwatch.Stop();
            timeElapsed[4] = stopwatch.ElapsedMilliseconds;
            Console.WriteLine("\nFull funcionality");
            TreeCenterTestCase.ResultOnly = false;

            stopwatch.Restart();
            treeCenter.PreformTests(verbose: true, checkTimeLimit: false, forceExecution: false);
            stopwatch.Stop();
            timeElapsed[5] = stopwatch.ElapsedMilliseconds;

            Console.WriteLine("\n\nPerformance metrics for the initial task tests");
            for (int i = 0; i < 6; i++)
            {
                Console.WriteLine("Testset {0}: {1,5} ms", i + 1, timeElapsed[i]);
            }



            // Nie radzę tych grafów próbować eksportować za pomocą GraphViz (mają sporo wierzchołków)
            // Wyjątek stanowi customTrees[0]
            Console.WriteLine("\n\nCustom tests");
            Console.WriteLine("Generating graphs. This may take a while");

            // Cycle in directed graphs
            Graph[] customDirectedGraphs = new Graph[5];
            customDirectedGraphs[0] = rgg.DirectedGraph(typeof(AdjacencyMatrixGraph), 100, 0.7);
            customDirectedGraphs[1] = rgg.DAG(typeof(AdjacencyListsGraph <AVLAdjacencyList>), 1000, 0.9, 1, 1);
            customDirectedGraphs[2] = rgg.DirectedCycle(typeof(AdjacencyListsGraph <AVLAdjacencyList>), 1000);
            customDirectedGraphs[3] = rgg.DirectedGraph(typeof(AdjacencyListsGraph <AVLAdjacencyList>), 1000, 0.5);
            customDirectedGraphs[4] = rgg.DirectedGraph(typeof(AdjacencyListsGraph <AVLAdjacencyList>), 1000, 0.7);

            TestSet customDirectedGraphsTestSet = new TestSet();

            customDirectedGraphsTestSet.TestCases.Add(new FindCycleTestCase(5, null, customDirectedGraphs[0], true));
            customDirectedGraphsTestSet.TestCases.Add(new FindCycleTestCase(5, null, customDirectedGraphs[1], false));
            customDirectedGraphsTestSet.TestCases.Add(new FindCycleTestCase(5, null, customDirectedGraphs[2], true));
            customDirectedGraphsTestSet.TestCases.Add(new FindCycleTestCase(5, null, customDirectedGraphs[3], true));
            customDirectedGraphsTestSet.TestCases.Add(new FindCycleTestCase(5, null, customDirectedGraphs[4], true));


            // Cycle in undirected graphs
            Graph[] customUndirectedGraphs = new Graph[5];
            customUndirectedGraphs[0] = rgg.UndirectedGraph(typeof(AdjacencyMatrixGraph), 100, 0.7);
            customUndirectedGraphs[1] = rgg.TreeGraph(typeof(AdjacencyListsGraph <AVLAdjacencyList>), 1000, 1);
            customUndirectedGraphs[2] = rgg.UndirectedCycle(typeof(AdjacencyListsGraph <AVLAdjacencyList>), 1000);
            customUndirectedGraphs[3] = rgg.UndirectedGraph(typeof(AdjacencyListsGraph <AVLAdjacencyList>), 1000, 0.5);
            customUndirectedGraphs[4] = rgg.UndirectedGraph(typeof(AdjacencyListsGraph <AVLAdjacencyList>), 1000, 0.7);

            TestSet customUndirectedGraphsTestSet = new TestSet();

            customUndirectedGraphsTestSet.TestCases.Add(new FindCycleTestCase(5, null, customUndirectedGraphs[0], true));
            customUndirectedGraphsTestSet.TestCases.Add(new FindCycleTestCase(5, null, customUndirectedGraphs[1], false));
            customUndirectedGraphsTestSet.TestCases.Add(new FindCycleTestCase(5, null, customUndirectedGraphs[2], true));
            customUndirectedGraphsTestSet.TestCases.Add(new FindCycleTestCase(5, null, customUndirectedGraphs[3], true));
            customUndirectedGraphsTestSet.TestCases.Add(new FindCycleTestCase(5, null, customUndirectedGraphs[4], true));

            // Tree center
            Graph[] customTrees = new Graph[5];
            customTrees[0] = new AdjacencyMatrixGraph(false, 1);
            customTrees[1] = rgg.TreeGraph(typeof(AdjacencyMatrixGraph), 100, 0.5);
            customTrees[2] = rgg.TreeGraph(typeof(AdjacencyListsGraph <SimpleAdjacencyList>), 100, 1);
            customTrees[3] = rgg.TreeGraph(typeof(AdjacencyListsGraph <AVLAdjacencyList>), 1000, 1);
            customTrees[4] = rgg.TreeGraph(typeof(AdjacencyListsGraph <AVLAdjacencyList>), 10000, 1);

            TestSet customTreeSet = new TestSet();

            customTreeSet.TestCases.Add(new TreeCenterTestCase(5, null, customTrees[0], true, new int[] { 0 }));
            customTreeSet.TestCases.Add(new TreeCenterTestCase(5, null, customTrees[1], false, null));
            customTreeSet.TestCases.Add(new TreeCenterTestCase(5, null, customTrees[2], true, new int[] { 77 }));
            customTreeSet.TestCases.Add(new TreeCenterTestCase(5, null, customTrees[3], true, new int[] { 146, 282 }));
            customTreeSet.TestCases.Add(new TreeCenterTestCase(5, null, customTrees[4], true, new int[] { 6780, 8396 }));



            Console.WriteLine("Custom cycle finding in directed graphs");
            stopwatch.Restart();
            customDirectedGraphsTestSet.PreformTests(verbose: true, checkTimeLimit: false, forceExecution: false);
            stopwatch.Stop();
            timeElapsed[6] = stopwatch.ElapsedMilliseconds;

            Console.WriteLine("Custom cycle finding in undirected graphs");
            stopwatch.Restart();
            customUndirectedGraphsTestSet.PreformTests(verbose: true, checkTimeLimit: false, forceExecution: false);
            stopwatch.Stop();
            timeElapsed[7] = stopwatch.ElapsedMilliseconds;

            Console.WriteLine("Custom tree center");
            stopwatch.Restart();
            customTreeSet.PreformTests(verbose: true, checkTimeLimit: false, forceExecution: false);
            stopwatch.Stop();
            timeElapsed[8] = stopwatch.ElapsedMilliseconds;


            Console.WriteLine("\n\nPerformance metrics for the custom tests");
            for (int i = 6; i < timeElapsed.Length; i++)
            {
                Console.WriteLine("Testset {0}: {1,5} ms", i + 1, timeElapsed[i]);
            }
        }