예제 #1
0
        private void Testing(ConverterGraphToDotEnum converterGraphToDotEnum)
        {
            try
            {
                // Variable
                ConvertGraphToDot convertGraphToDot;

                testPath = ReaderWriter.ReaderWriter.CreateTestFile(testsDictionary[converterGraphToDotEnum]);

                reader = new ReaderWriter.ReaderGraph(testPath, false);
                graph  = reader.ReadFile();

                List <Graph.IGraphInterface> graphList = graph.GetGraphProperty().GetComponents();

                stringBuilder.AppendLine(converterGraphToDotEnum.ToString());
                stringBuilder.AppendLine(graph.ToString());

                stringBuilder.AppendLine("Standard graph");
                convertGraphToDot = new ConvertGraphToDot(graphList, false, true, true, true, true);
                stringBuilder.AppendLine(convertGraphToDot.Convert());

                stringBuilder.AppendLine("Uncolored schedule");
                convertGraphToDot = new ConvertGraphToDot(graphList, true, true, true, true, true);
                stringBuilder.AppendLine(convertGraphToDot.Convert());

                GraphColoringAlgorithm.SequenceAlgorithm.LargestFirstSequence.LargestFirstSequence largestFirstSequence;
                foreach (Graph.IGraphInterface graph in graphList)
                {
                    largestFirstSequence = new GraphColoringAlgorithm.SequenceAlgorithm.LargestFirstSequence.LargestFirstSequence(graph, GraphColoringAlgorithm.GraphColoringAlgorithm.GraphColoringAlgorithInterchangeEnum.none);
                    largestFirstSequence.Color();
                }

                stringBuilder.AppendLine("Colored schedule");
                convertGraphToDot = new ConvertGraphToDot(graphList, true, true, true, true, true);
                stringBuilder.AppendLine(convertGraphToDot.Convert());
            }
            catch (KeyNotFoundException)
            {
                throw new MyException.TestsException.TestsMissingTestException(converterGraphToDotEnum.ToString());
            }
            catch (MyException.ReaderWriterException.ReaderWriterException e)
            {
                stringBuilder.AppendLine(e.Message);
            }
        }
예제 #2
0
        private void Testing(PathEnum pathEnum)
        {
            try
            {
                Graph.IGraphInterface graph;
                GraphColoringAlgorithm.SequenceAlgorithm.RandomSequence.RandomSequence             randomSequence;
                GraphColoringAlgorithm.SequenceAlgorithm.LargestFirstSequence.LargestFirstSequence largestFirstSequence;
                testPath = ReaderWriter.CreateTestFile(testsDictionary[pathEnum]);
                reader   = new ReaderGraph(testPath, false);
                writer   = new WriterGraph(testPath, false);

                stringBuilder.AppendLine(pathEnum.ToString());
                try
                {
                    switch (pathEnum)
                    {
                    case PathEnum.write:
                        graph          = reader.ReadFile();
                        randomSequence = new GraphColoringAlgorithm.SequenceAlgorithm.RandomSequence.RandomSequence(graph);
                        randomSequence.Color();
                        writer.WriteFileColor(graph, GraphColoringAlgorithm.GraphColoringAlgorithm.GraphColoringAlgorithmEnum.randomSequence, false);
                        reader.ReadFile();
                        stringBuilder.AppendLine("OK");
                        break;

                    case PathEnum.recordExists:
                        graph = reader.ReadFile();
                        largestFirstSequence = new GraphColoringAlgorithm.SequenceAlgorithm.LargestFirstSequence.LargestFirstSequence(graph);
                        largestFirstSequence.Color();
                        if (!writer.WriteFileColor(graph, GraphColoringAlgorithm.GraphColoringAlgorithm.GraphColoringAlgorithmEnum.largestFirstSequence, false))
                        {
                            stringBuilder.AppendLine("OK");
                        }
                        else
                        {
                            stringBuilder.AppendLine("NOK");
                        }
                        reader.ReadFile();
                        break;

                    case PathEnum.first:
                        graph          = reader.ReadFile();
                        randomSequence = new GraphColoringAlgorithm.SequenceAlgorithm.RandomSequence.RandomSequence(graph);
                        randomSequence.Color();
                        writer.WriteFileColor(graph, GraphColoringAlgorithm.GraphColoringAlgorithm.GraphColoringAlgorithmEnum.randomSequence, false);
                        reader.ReadFile();
                        stringBuilder.AppendLine("OK");
                        break;

                    default:
                        stringBuilder.AppendLine("This pathEnum isn't implemented!");
                        break;
                    }
                }
                catch (MyException.ReaderWriterException.ReaderWriterException e)
                {
                    stringBuilder.AppendLine(e.Message);
                }
                catch (MyException.GraphException.GraphException e)
                {
                    stringBuilder.AppendLine(e.Message);
                }
            }
            catch (KeyNotFoundException)
            {
                throw new MyException.TestsException.TestsMissingTestException(pathEnum.ToString());
            }
            catch (MyException.ReaderWriterException.ReaderWriterException e)
            {
                stringBuilder.AppendLine(e.Message);
            }
        }