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);
            }
        }
 public static IEnumerable<object[]> GetRandomGraphs500Vertices()
 {
     int vertices = 500;
     var data = new List<object[]>();
     Graph g;
     for (int i = 0; i < 5; i++)
     {
         g = ColoringTestUtils.GenerateGraph(verticesCount: vertices, maxNeighbours: 4, delta: 4, isColorable: true);
         data.Add(new[] { g });
         g = ColoringTestUtils.GenerateGraph(verticesCount: vertices, maxNeighbours: 4, verticesWithHighDegree: 0.005, isColorable: true);
         data.Add(new[] { g });
         g = ColoringTestUtils.GenerateGraph(verticesCount: vertices, maxNeighbours: 5, delta: 2, verticesWithHighDegree: 0.02, isColorable: false);
         data.Add(new[] { g });
         g = ColoringTestUtils.GenerateGraph(verticesCount: vertices, maxNeighbours: 6, delta: 5, verticesWithHighDegree: 0.02, isColorable: false);
         data.Add(new[] { g });
     }
     return data;
 }
Exemplo n.º 3
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.º 4
0
 public static IEnumerable <object[]> GetData() => ColoringTestUtils.GetData();
Exemplo n.º 5
0
        public void TestColoringSuccesfull(Graph g)
        {
            var coloring = new CspColoring().ThreeColorig(g);

            ColoringTestUtils.CheckColoringCorrectness(g, coloring);
        }
 public void RandomGraphs600VerticesTest(Graph g)
 {
     ColoringTestUtils.CheckAndWriteOutput(g);
 }
 public void GeneratorTest()
 {
     Graph g = ColoringTestUtils.GenerateGraph(verticesCount: 200, isColorable: true, maxNeighbours: 5);
     Assert.NotNull(g);
 }