private void sameStructure(string[,] edges) { SingleGraph singleGraph = new SingleGraph(edges); Console.Write("How many edges does your second graph have? "); int n = int.Parse(Console.ReadLine()); Console.WriteLine("Enter your edges below: "); string[,] secondEdges = new string[n, 2]; for (int i = 0; i < secondEdges.GetLength(0); i++) { string[] edge = Console.ReadLine().Split(" ".ToCharArray()); secondEdges[i, 0] = edge[0]; secondEdges[i, 1] = edge[1]; } SingleGraph secondGraph = new SingleGraph(secondEdges); if (singleGraph.GetVerticals().Count != secondGraph.GetVerticals().Count) { Console.WriteLine("They are not the same"); return; } Permutation permutation = new Permutation(singleGraph.GetVerticals().Count, singleGraph.GetVerticals().Count); bool found = true; foreach (List <int> e in permutation.Result) { found = true; List <string> specifiedVerticals = new List <string>(); foreach (int e1 in e) { specifiedVerticals.Add(singleGraph.GetVerticals()[e1 - 1]); } int[,] firstMatrix = singleGraph.makeMatrix(specifiedVerticals); int[,] secondMatrix = secondGraph.makeMatrix(secondGraph.GetVerticals()); for (int i = 0; i < firstMatrix.GetLength(0); i++) { for (int j = 0; j < firstMatrix.GetLength(1); j++) { if (firstMatrix[i, j] != secondMatrix[i, j]) { found = false; break; } } } if (found) { Console.WriteLine("They are the same"); return; } } if (!found) { Console.WriteLine("They are not the same"); } }
private void colorGraph(string[,] edges) { SingleGraph singleGraph = new SingleGraph(edges); int[] colors = singleGraph.colorGraph(); Console.Write("The color of verticals " + produceVerticalString(singleGraph) + "respectively are: "); foreach (int e in colors) { Console.Write(e + " "); } Console.WriteLine(""); }
private void theShortestRoad(string[,] edges) { SingleGraph singleGraph = new SingleGraph(edges); Console.WriteLine("Enter the length of the edges below:"); List <int> length = new List <int>(); for (int i = 0; i < edges.GetLength(0); i++) { length.Add(int.Parse(Console.ReadLine())); } singleGraph.Length = length; Console.Write("Where do you want to start: "); string start = Console.ReadLine(); Console.Write("Where do you want to stop: "); string end = Console.ReadLine(); singleGraph.shortestRoad(start, end); }
private void SingleDividableResult(string[,] edges) { SingleGraph graph = new SingleGraph(edges); Console.WriteLine("The given single graph is devisable? " + graph.Devidable()); }