Exemplo n.º 1
0
        private void CheckAndWriteOutput(Graph g, string additionalInfo = "")
        {
            if (additionalInfo != "")
            {
                output.WriteLine(additionalInfo);
            }
            Stopwatch sw = new();

            sw.Reset();
            sw.Start();
            var brut = new BruteForce().ThreeColorig(g);

            sw.Stop();
            output.WriteLine($"Graph with {g.VerticesCount} vertices:");
            var found = brut == null ? "No" : "Yes";

            output.WriteLine($"Brute time: {sw.Elapsed}. Found:  {found}");
            sw.Reset();
            sw.Start();
            var super = new CspColoring().ThreeColorig(g);

            sw.Stop();
            found = super == null ? "No" : "Yes";
            output.WriteLine($"CSP   time: {sw.Elapsed}. Found:  {found}");
            output.WriteLine("-----------------------------------------------");
            if (brut == null)
            {
                Assert.Null(super);
            }
            else
            {
                ColoringTestUtils.CheckColoringCorrectness(g, super);
            }
        }
Exemplo n.º 2
0
        public static void CheckAndWriteOutput(Graph g)
        {
            Stopwatch sw = new();

            sw.Reset();
            sw.Start();
            var super = new CspColoring().ThreeColorig(g);

            sw.Stop();
            var found = super == null ? "No" : "Yes";

            if (super != null)
            {
                ColoringTestUtils.CheckColoringCorrectness(g, super);
            }
            File.AppendAllLines(@"..\result.txt", new string[]
                                { $"Graph with {g.VerticesCount} vertices:"
                                  , $"CSP   time: {sw.Elapsed}. Found:  {found}"
                                  , "-----------------------------------------------" });
        }
Exemplo n.º 3
0
        public void TestColoringSuccesfull(Graph g)
        {
            var coloring = new CspColoring().ThreeColorig(g);

            ColoringTestUtils.CheckColoringCorrectness(g, coloring);
        }