private void Testing(ModificationEnum modificationEnum) { try { testPath = ReaderWriter.ReaderWriter.CreateTestFile(testsDictionary[modificationEnum]); reader = new ReaderWriter.ReaderGraph(testPath, false); graph = reader.ReadFile(); stringBuilder.AppendLine(modificationEnum.ToString()); stringBuilder.AppendLine("Graph created."); stringBuilder.AppendLine(graph.ToString()); switch (modificationEnum) { case ModificationEnum.valid: Valid(graph); break; case ModificationEnum.invalid: Invalid(graph); break; default: throw new MyException.TestsException.TestsMissingTestException(modificationEnum.ToString()); } stringBuilder.AppendLine("Graph modified."); stringBuilder.AppendLine(graph.ToString()); } catch (KeyNotFoundException) { throw new MyException.TestsException.TestsMissingTestException(modificationEnum.ToString()); } }
private void Testing(ComplementEnum complementEnum) { try { testPath = ReaderWriter.ReaderWriter.CreateTestFile(testsDictionary[complementEnum]); reader = new ReaderWriter.ReaderGraph(testPath, false); graph = reader.ReadFile(); stringBuilder.AppendLine(complementEnum.ToString()); stringBuilder.AppendLine("Graph created."); stringBuilder.AppendLine(graph.ToString()); IGraphInterface graphComplement = GraphOperation.ComplementGraph(graph); stringBuilder.AppendLine("Complement graph."); stringBuilder.AppendLine(graphComplement.ToString()); } catch (KeyNotFoundException) { throw new MyException.TestsException.TestsMissingTestException(complementEnum.ToString()); } catch (MyException.ReaderWriterException.ReaderWriterException e) { stringBuilder.AppendLine(e.Message); } }
private void Testing(CycleEnum cycleEnum) { try { testPath = ReaderWriter.ReaderWriter.CreateTestFile(testsDictionary[cycleEnum]); reader = new ReaderWriter.ReaderGraph(testPath, false); graph = reader.ReadFile(); stringBuilder.AppendLine(cycleEnum.ToString()); stringBuilder.AppendLine("Graph created."); stringBuilder.AppendLine(graph.ToString()); stringBuilder.AppendLine("Is graph cyclic: " + graph.GetGraphProperty().GetIsCyclic()); stringBuilder.AppendLine("Gridth: " + graph.GetGraphProperty().GetGirth()); } catch (KeyNotFoundException) { throw new MyException.TestsException.TestsMissingTestException(cycleEnum.ToString()); } catch (MyException.ReaderWriterException.ReaderWriterException e) { stringBuilder.AppendLine(e.Message); } }
private void Testing(ClassEnum classEnum) { try { testPath = ReaderWriter.ReaderWriter.CreateTestFile(testsDictionary[classEnum]); reader = new ReaderWriter.ReaderGraph(testPath, false); graph = reader.ReadFile(); stringBuilder.AppendLine(classEnum.ToString()); stringBuilder.AppendLine("Graph created."); stringBuilder.AppendLine(graph.ToString()); GraphClass.GraphClassEnum graphClassEnum = GraphClass.GetGraphClass(graph); stringBuilder.AppendLine("Graph class: " + graphClassEnum.ToString()); } catch (KeyNotFoundException) { throw new MyException.TestsException.TestsMissingTestException(classEnum.ToString()); } catch (MyException.ReaderWriterException.ReaderWriterException e) { stringBuilder.AppendLine(e.Message); } }
private void Testing(SubGraphEnum subGraphEnum) { try { testPath = ReaderWriter.ReaderWriter.CreateTestFile(testsDictionary[subGraphEnum].Item1); countVertices = testsDictionary[subGraphEnum].Item2; reader = new ReaderWriter.ReaderGraph(testPath, false); graph = reader.ReadFile(); stringBuilder.AppendLine(subGraphEnum.ToString()); stringBuilder.AppendLine("Graph created."); stringBuilder.AppendLine(graph.ToString()); IGraphInterface subGraph = GraphOperation.SubGraph(graph, graph.AllVertices().Take(countVertices).ToList()); stringBuilder.AppendLine("Subgraph created."); stringBuilder.AppendLine(subGraph.ToString()); } catch (KeyNotFoundException) { throw new MyException.TestsException.TestsMissingTestException(subGraphEnum.ToString()); } catch (MyException.ReaderWriterException.ReaderWriterException e) { stringBuilder.AppendLine(e.Message); } }
private void Testing(ChordalTestEnum chordalEnum) { try { testPath = ReaderWriter.ReaderWriter.CreateTestFile(testsDictionary[chordalEnum]); reader = new ReaderWriter.ReaderGraph(testPath, false); graph = reader.ReadFile(); stringBuilder.AppendLine(chordalEnum.ToString()); stringBuilder.AppendLine("Graph created."); stringBuilder.AppendLine(graph.ToString()); stringBuilder.AppendLine("isChordal " + graph.GetGraphProperty().GetIsChordal()); foreach (IVertexInterface vertex in graph.GetGraphProperty().GetPerfectEliminationOrdering()) { stringBuilder.AppendLine("- " + vertex.GetIdentifier()); } } catch (KeyNotFoundException) { throw new MyException.TestsException.TestsMissingTestException(chordalEnum.ToString()); } catch (MyException.ReaderWriterException.ReaderWriterException e) { stringBuilder.AppendLine(e.Message); } catch (MyException.GraphException.GraphIsNotConnected e) { stringBuilder.AppendLine(e.Message); } }
private void Testing(SpanningTreeEnum spanningTreeEnum) { try { testPath = ReaderWriter.ReaderWriter.CreateTestFile(testsDictionary[spanningTreeEnum]); reader = new ReaderWriter.ReaderGraph(testPath, false); graph = reader.ReadFile(); stringBuilder.AppendLine(spanningTreeEnum.ToString()); stringBuilder.AppendLine("Graph created."); stringBuilder.AppendLine(graph.ToString()); stringBuilder.AppendLine("SpanningTree: "); List <IEdgeInterface> spanningTreeList = graph.GetGraphProperty().GetSpanningTree(); foreach (IEdgeInterface edge in spanningTreeList) { stringBuilder.AppendLine(edge.ToString()); } } catch (KeyNotFoundException) { throw new MyException.TestsException.TestsMissingTestException(spanningTreeEnum.ToString()); } catch (MyException.ReaderWriterException.ReaderWriterException e) { stringBuilder.AppendLine(e.Message); } }
private void Testing(ComponentEnum componentEnum) { try { testPath = ReaderWriter.ReaderWriter.CreateTestFile(testsDictionary[componentEnum]); reader = new ReaderWriter.ReaderGraph(testPath, false); graph = reader.ReadFile(); stringBuilder.AppendLine(componentEnum.ToString()); stringBuilder.AppendLine("Graph created."); stringBuilder.AppendLine(graph.ToString()); stringBuilder.AppendLine("Number of components: " + graph.GetGraphProperty().GetCountComponents()); stringBuilder.AppendLine("Is graph connected: " + graph.GetGraphProperty().GetIsConnected()); stringBuilder.AppendLine("Circuit rank: " + graph.GetGraphProperty().GetCircuitRank()); graphComponentList = graph.GetGraphProperty().GetComponents(); foreach (Graph graphComponent in graphComponentList) { stringBuilder.AppendLine("Graph component."); stringBuilder.AppendLine(graphComponent.ToString()); } } catch (KeyNotFoundException) { throw new MyException.TestsException.TestsMissingTestException(componentEnum.ToString()); } catch (MyException.ReaderWriterException.ReaderWriterException e) { stringBuilder.AppendLine(e.Message); } }
private void Testing(DegreeSequenceEnum degreeSequenceEnum) { try { testPath = ReaderWriter.ReaderWriter.CreateTestFile(testsDictionary[degreeSequenceEnum]); reader = new ReaderWriter.ReaderGraph(testPath, false); graph = reader.ReadFile(); stringBuilder.AppendLine(degreeSequenceEnum.ToString()); stringBuilder.AppendLine("Graph created."); stringBuilder.AppendLine(graph.ToString()); // Sorted List <int> degreeSequenceList = graph.GetGraphProperty().GetDegreeSequenceInt(true); stringBuilder.AppendLine("Degree sequence"); foreach (int degree in degreeSequenceList) { stringBuilder.Append(degree + " "); } stringBuilder.AppendLine(""); stringBuilder.AppendLine("Minimum vertex degree: " + graph.GetGraphProperty().GetMinimumVertexDegree()); stringBuilder.AppendLine("Maximum vertex degree: " + graph.GetGraphProperty().GetMaximumVertexDegree()); stringBuilder.AppendLine("Average vertex degree: " + graph.GetGraphProperty().GetAverageVertexDegree()); stringBuilder.AppendLine("Is graph regular: " + graph.GetGraphProperty().GetIsRegular()); graph.GetGraphProperty().Reset(); // Unsorted degreeSequenceList = graph.GetGraphProperty().GetDegreeSequenceInt(false); stringBuilder.AppendLine("Degree sequence"); foreach (int degree in degreeSequenceList) { stringBuilder.Append(degree + " "); } stringBuilder.AppendLine(""); stringBuilder.AppendLine("Minimum vertex degree: " + graph.GetGraphProperty().GetMinimumVertexDegree()); stringBuilder.AppendLine("Maximum vertex degree: " + graph.GetGraphProperty().GetMaximumVertexDegree()); stringBuilder.AppendLine("Average vertex degree: " + graph.GetGraphProperty().GetAverageVertexDegree()); stringBuilder.AppendLine("Is graph regular: " + graph.GetGraphProperty().GetIsRegular()); } catch (KeyNotFoundException) { throw new MyException.TestsException.TestsMissingTestException(degreeSequenceEnum.ToString()); } catch (MyException.ReaderWriterException.ReaderWriterException e) { stringBuilder.AppendLine(e.Message); } }
private void Testing(ColoredGraphEnum coloredGraphEnum) { try { testPath = ReaderWriter.ReaderWriter.CreateTestFile(testsDictionary[coloredGraphEnum]); reader = new ReaderWriter.ReaderGraph(testPath, false); graph = reader.ReadFile(); stringBuilder.AppendLine(coloredGraphEnum.ToString()); stringBuilder.AppendLine("Graph created."); stringBuilder.AppendLine(graph.ToString()); switch (coloredGraphEnum) { case ColoredGraphEnum.valid: Valid(graph); stringBuilder.AppendLine("Graph modified."); break; case ColoredGraphEnum.invalid: Invalid(graph); stringBuilder.AppendLine("Graph modified."); break; case ColoredGraphEnum.interchange1: case ColoredGraphEnum.interchange2: case ColoredGraphEnum.interchange3: case ColoredGraphEnum.interchange4: case ColoredGraphEnum.interchange5: graph.GetColoredGraph().GreedyColoring(graph.AllVertices(), GraphColoringAlgorithm.GraphColoringAlgorithm.GraphColoringAlgorithInterchangeEnum.interchange); stringBuilder.AppendLine("Graph colored."); break; default: throw new MyException.TestsException.TestsMissingTestException(coloredGraphEnum.ToString()); } stringBuilder.AppendLine(graph.GetColoredGraph().ToString()); } catch (KeyNotFoundException) { throw new MyException.TestsException.TestsMissingTestException(coloredGraphEnum.ToString()); } catch (MyException.GraphException.GraphException e) { stringBuilder.AppendLine(e.ToString()); } }
private void Testing(BridgesCutVerticesEnum bridgesCutVerticesEnum) { try { testPath = ReaderWriter.ReaderWriter.CreateTestFile(testsDictionary[bridgesCutVerticesEnum]); reader = new ReaderWriter.ReaderGraph(testPath, false); graph = reader.ReadFile(); stringBuilder.AppendLine(bridgesCutVerticesEnum.ToString()); stringBuilder.AppendLine("Graph created."); stringBuilder.AppendLine(graph.ToString()); stringBuilder.AppendLine("Number of cut vertices: " + graph.GetGraphProperty().GetCutVertices().Count); stringBuilder.AppendLine("Cut vertices: "); graph.GetGraphProperty().GetCutVertices().ForEach(x => { stringBuilder.AppendLine(x.GetUserName()); }); stringBuilder.AppendLine("Number of bridges: " + graph.GetGraphProperty().GetBridges().Count); stringBuilder.AppendLine("Bridges: "); graph.GetGraphProperty().GetBridges().ForEach(x => { stringBuilder.AppendLine(x.GetVertex1().GetUserName() + " " + x.GetVertex2().GetUserName()); }); graph.GetGraphProperty().Reset(); stringBuilder.AppendLine("Number of cut vertices: " + graph.GetGraphProperty().GetCutVertices().Count); stringBuilder.AppendLine("Number of bridges: " + graph.GetGraphProperty().GetBridges().Count); } catch (KeyNotFoundException) { throw new MyException.TestsException.TestsMissingTestException(bridgesCutVerticesEnum.ToString()); } catch (MyException.ReaderWriterException.ReaderWriterException e) { stringBuilder.AppendLine(e.Message); } catch (MyException.GraphException.GraphIsNotConnected e) { stringBuilder.AppendLine(e.Message); } }