public static void Main(string[] args) { if (GraphLibraryVersion.ToString() != "7.0.2") { Console.WriteLine("Pobierz nową wersję biblioteki"); return; } Graph triplePath = new AdjacencyListsGraph <SimpleAdjacencyList>(false, 5); triplePath.AddEdge(0, 1); triplePath.AddEdge(0, 2); triplePath.AddEdge(0, 3); triplePath.AddEdge(4, 1); triplePath.AddEdge(4, 2); triplePath.AddEdge(4, 3); Graph grid5 = new AdjacencyListsGraph <SimpleAdjacencyList>(false, 25); for (int i = 0; i < 5; i++) { for (int j = 0; j < 4; j++) { grid5.AddEdge(5 * i + j, 5 * i + j + 1); grid5.AddEdge(5 * j + i, 5 * (j + 1) + i); } } Graph crossing = new AdjacencyListsGraph <SimpleAdjacencyList>(false, 5); crossing.AddEdge(0, 4); crossing.AddEdge(1, 4); crossing.AddEdge(2, 4); crossing.AddEdge(3, 4); MuseumTestCase triplePathCase = new MuseumTestCase(10, triplePath, new int[] { 3, 1, 1, 1, 3 }, new int[] { 0 }, new int[] { 4 }, 3); MuseumTestCase doublePathCase = new MuseumTestCase(10, triplePath, new int[] { 1, 1, 1, 1, 1 }, new int[] { 0, 4 }, new int[] { 0, 4 }, 2); MuseumTestCase singleVertexCase1 = new MuseumTestCase(10, triplePath, new int[] { 1, 1, 1, 1, 1 }, new int[] { 0 }, new int[] { 0 }, 1); MuseumTestCase singleVertexCase2 = new MuseumTestCase(10, triplePath, new int[] { 2, 1, 1, 1, 2 }, new int[] { 0 }, new int[] { 4 }, 2); MuseumTestCase doubledPathCase = new MuseumTestCase(10, triplePath, new int[] { 6, 2, 2, 2, 6 }, new int[] { 0 }, new int[] { 4 }, 6); MuseumTestCase almostDoubledPathCase = new MuseumTestCase(10, triplePath, new int[] { 6, 2, 2, 2, 5 }, new int[] { 0 }, new int[] { 4 }, 5); MuseumTestCase almostDoubledPathCase2 = new MuseumTestCase(10, triplePath, new int[] { 5, 2, 2, 2, 6 }, new int[] { 0 }, new int[] { 4 }, 5); MuseumTestCase middleVertexLimit = new MuseumTestCase(10, crossing, new int[] { 1, 1, 1, 1, 1 }, new int[] { 0, 1 }, new int[] { 2, 3 }, 1); MuseumTestCase centerToCornersGrid = new MuseumTestCase(10, grid5, new int[] { 1, 3, 3, 3, 2, 0, 3, 0, 0, 0, 0, 4, 6, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1 }, new int[] { 12 }, new int[] { 0, 4, 20, 24 }, 5); MuseumTestCase cornersToCenterGrid = new MuseumTestCase(10, grid5, new int[] { 1, 3, 3, 3, 2, 0, 3, 0, 0, 0, 0, 4, 6, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1 }, new int[] { 0, 4, 20, 24 }, new int[] { 12 }, 5); TestSet set = new TestSet(); set.TestCases.Add(triplePathCase); set.TestCases.Add(doublePathCase); set.TestCases.Add(singleVertexCase1); set.TestCases.Add(singleVertexCase2); set.TestCases.Add(doubledPathCase); set.TestCases.Add(almostDoubledPathCase); set.TestCases.Add(almostDoubledPathCase2); set.TestCases.Add(middleVertexLimit); set.TestCases.Add(centerToCornersGrid); set.TestCases.Add(cornersToCenterGrid); set.TestCases.Add(MuseumTestCase.RandomTest(100, 1337, 10, 204)); set.TestCases.Add(MuseumTestCase.RandomTest(100, 1410, 10, 181)); set.TestCases.Add(MuseumTestCase.RandomTest(100, 240044, 10, 128)); MuseumTestCase.NumberOnly = true; Console.WriteLine("\nCzesc I\n"); set.PreformTests(verbose: true, checkTimeLimit: false); MuseumTestCase.NumberOnly = false; Console.WriteLine("\nCzesc II\n"); set.PreformTests(verbose: true, checkTimeLimit: false); }
public static void Main(string[] args) { if (GraphLibraryVersion.ToString() != "7.0.2") { Console.WriteLine("Pobierz nową wersję biblioteki"); return; } Graph triplePath = new AdjacencyListsGraph <SimpleAdjacencyList>(false, 5); triplePath.AddEdge(0, 1); triplePath.AddEdge(0, 2); triplePath.AddEdge(0, 3); triplePath.AddEdge(4, 1); triplePath.AddEdge(4, 2); triplePath.AddEdge(4, 3); Graph grid5 = new AdjacencyListsGraph <SimpleAdjacencyList>(false, 25); for (int i = 0; i < 5; i++) { for (int j = 0; j < 4; j++) { grid5.AddEdge(5 * i + j, 5 * i + j + 1); grid5.AddEdge(5 * j + i, 5 * (j + 1) + i); } } Graph crossing = new AdjacencyListsGraph <SimpleAdjacencyList>(false, 5); crossing.AddEdge(0, 4); crossing.AddEdge(1, 4); crossing.AddEdge(2, 4); crossing.AddEdge(3, 4); MuseumTestCase triplePathCase = new MuseumTestCase(10, triplePath, new int[] { 3, 1, 1, 1, 3 }, new int[] { 0 }, new int[] { 4 }, 3); MuseumTestCase doublePathCase = new MuseumTestCase(10, triplePath, new int[] { 1, 1, 1, 1, 1 }, new int[] { 0, 4 }, new int[] { 0, 4 }, 2); MuseumTestCase singleVertexCase1 = new MuseumTestCase(10, triplePath, new int[] { 1, 1, 1, 1, 1 }, new int[] { 0 }, new int[] { 0 }, 1); MuseumTestCase singleVertexCase2 = new MuseumTestCase(10, triplePath, new int[] { 2, 1, 1, 1, 2 }, new int[] { 0 }, new int[] { 4 }, 2); MuseumTestCase doubledPathCase = new MuseumTestCase(10, triplePath, new int[] { 6, 2, 2, 2, 6 }, new int[] { 0 }, new int[] { 4 }, 6); MuseumTestCase almostDoubledPathCase = new MuseumTestCase(10, triplePath, new int[] { 6, 2, 2, 2, 5 }, new int[] { 0 }, new int[] { 4 }, 5); MuseumTestCase almostDoubledPathCase2 = new MuseumTestCase(10, triplePath, new int[] { 5, 2, 2, 2, 6 }, new int[] { 0 }, new int[] { 4 }, 5); MuseumTestCase middleVertexLimit = new MuseumTestCase(10, crossing, new int[] { 1, 1, 1, 1, 1 }, new int[] { 0, 1 }, new int[] { 2, 3 }, 1); MuseumTestCase centerToCornersGrid = new MuseumTestCase(10, grid5, new int[] { 1, 3, 3, 3, 2, 0, 3, 0, 0, 0, 0, 4, 6, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1 }, new int[] { 12 }, new int[] { 0, 4, 20, 24 }, 5); MuseumTestCase cornersToCenterGrid = new MuseumTestCase(10, grid5, new int[] { 1, 3, 3, 3, 2, 0, 3, 0, 0, 0, 0, 4, 6, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1 }, new int[] { 0, 4, 20, 24 }, new int[] { 12 }, 5); TestSet set = new TestSet(); set.TestCases.Add(triplePathCase); set.TestCases.Add(doublePathCase); set.TestCases.Add(singleVertexCase1); set.TestCases.Add(singleVertexCase2); set.TestCases.Add(doubledPathCase); set.TestCases.Add(almostDoubledPathCase); set.TestCases.Add(almostDoubledPathCase2); set.TestCases.Add(middleVertexLimit); set.TestCases.Add(centerToCornersGrid); set.TestCases.Add(cornersToCenterGrid); set.TestCases.Add(MuseumTestCase.RandomTest(100, 1337, 10, 204)); set.TestCases.Add(MuseumTestCase.RandomTest(100, 1410, 10, 181)); set.TestCases.Add(MuseumTestCase.RandomTest(100, 240044, 10, 128)); MuseumTestCase.NumberOnly = true; Console.WriteLine("\nCzesc I\n"); set.PreformTests(verbose: true, checkTimeLimit: false); MuseumTestCase.NumberOnly = false; Console.WriteLine("\nCzesc II\n"); set.PreformTests(verbose: true, checkTimeLimit: false); // Custom tests Console.WriteLine("\nPerforming boilerplate task"); long boilerplateTaskTime = PerformBoilerplateTask(); Console.WriteLine("Custom tests\n"); TestSet customSet = new TestSet(); customSet.TestCases.Add(MuseumTestCase.RandomTest(100, 69, 10, 116)); customSet.TestCases.Add(MuseumTestCase.RandomTest(150, 70, 10, 91)); customSet.TestCases.Add(MuseumTestCase.RandomTest(150, 71, 10, 170)); customSet.TestCases.Add(MuseumTestCase.RandomTest(150, 72, 10, 95)); customSet.TestCases.Add(MuseumTestCase.RandomTest(150, 73, 10, 99)); customSet.TestCases.Add(MuseumTestCase.RandomTest(150, 74, 10, 307)); customSet.TestCases.Add(MuseumTestCase.RandomTest(200, 75, 10, 485)); customSet.TestCases.Add(MuseumTestCase.RandomTest(200, 76, 10, 219)); customSet.TestCases.Add(MuseumTestCase.RandomTest(200, 77, 10, 0)); customSet.TestCases.Add(MuseumTestCase.RandomTest(200, 78, 10, 536)); customSet.TestCases.Add(MuseumTestCase.RandomTest(250, 79, 10, 424)); customSet.TestCases.Add(MuseumTestCase.RandomTest(250, 80, 10, 58)); customSet.TestCases.Add(MuseumTestCase.RandomTest(250, 81, 10, 387)); customSet.TestCases.Add(MuseumTestCase.RandomTest(250, 82, 10, 635)); customSet.TestCases.Add(MuseumTestCase.RandomTest(300, 83, 10, 657)); customSet.TestCases.Add(MuseumTestCase.RandomTest(300, 84, 10, 551)); customSet.TestCases.Add(MuseumTestCase.RandomTest(500, 85, 10, 289)); customSet.TestCases.Add(MuseumTestCase.RandomTest(500, 86, 10, 969)); customSet.TestCases.Add(MuseumTestCase.RandomTest(500, 87, 10, 1238)); customSet.TestCases.Add(MuseumTestCase.RandomTest(750, 88, 10, 1722)); customSet.TestCases.Add(MuseumTestCase.RandomTest(1000, 89, 10, 2257)); var stopwatch = System.Diagnostics.Stopwatch.StartNew(); customSet.PreformTests(verbose: true, checkTimeLimit: false); stopwatch.Stop(); long customTestsTime = stopwatch.ElapsedMilliseconds; Console.WriteLine("Custom tests: {0,5} ms ({1:F3} times the boilerplate time)", customTestsTime, (double)customTestsTime / boilerplateTaskTime); }