public async Task <IActionResult> GetChinesePostman() { // var graph = Initializing.CreateGraph(@"../Graph/_ChinesePostman.txt"); var matrix = new int[8, 8] { { 0, 0, 0, 0, 86, 94, 51, 82 }, { 0, 0, 81, 0, 20, 87, 0, 0 }, { 0, 81, 0, 83, 41, 0, 0, 0 }, { 0, 0, 83, 0, 8, 0, 0, 0 }, { 86, 20, 41, 8, 0, 40, 0, 54 }, { 94, 87, 0, 0, 40, 0, 89, 0 }, { 51, 0, 0, 0, 0, 89, 0, 18 }, { 82, 0, 0, 0, 54, 0, 18, 0 }, }; var graph = Initializing.CreateGraph(matrix); Graph newGraph = new Graph(); if (!ChinesePostman.ChinesePostman.IsEvenDegree(graph.Nodes)) { var oddNodes = OddFinder.FindOddNodes(graph.Nodes); newGraph = ChinesePostman.ChinesePostman.PairingOddVertices(graph, oddNodes); } var eulerianPath = ChinesePostman.ChinesePostman.FindEulerianPath(newGraph); newGraph.Nodes = eulerianPath.ToArray(); List <Graph> fullResponse = new List <Graph> { graph, newGraph }; return(Ok(fullResponse)); }
public async Task <IActionResult> GetChinesePostman() { var graph = Initializing.CreateGraph(@"../Graph/_ChinesePostman.txt"); Graph newGraph = new Graph(); if (!ChinesePostman.ChinesePostman.IsEvenDegree(graph.Nodes)) { var oddNodes = OddFinder.FindOddNodes(graph.Nodes); newGraph = ChinesePostman.ChinesePostman.PairingOddVertices(graph, oddNodes); } var eulerianPath = ChinesePostman.ChinesePostman.FindEulerianPath(newGraph); newGraph.Nodes = eulerianPath.ToArray(); List <Graph> fullResponse = new List <Graph> { graph, newGraph }; return(Ok(fullResponse)); }
public static void GetChinesePostman() { var graph = Initializing.CreateGraph(@"./_Second.txt"); Graph newGraph = new Graph(); if (!ChinesePostman.IsEvenDegree(graph.Nodes)) { var oddNodes = OddFinder.FindOddNodes(graph.Nodes); newGraph = ChinesePostman.PairingOddVertices(graph, oddNodes); } var eulerianPath = ChinesePostman.FindEulerianPath(newGraph); System.Console.WriteLine("\n"); ConsolePrint.HeaderPrint("Chinese postman problem"); ConsolePrint.PrintGraph(graph); ConsolePrint.ShowAdditionalEdges(graph, newGraph); // ConsolePrint.PrintNodes(graph.Nodes, newGraph.Nodes); ConsolePrint.PrintPath(eulerianPath.ToArray()); }
public static void GetPostman() { var graph = Initializing.CreateGraph(@"./postman.txt"); var matrix = Initializing.CreateMatrix(@"./postman.txt"); Graph newGraph = new Graph(); if (!Postman.IsEvenDegree(graph.Nodes)) { var oddNodes = OddFinder.FindOddNodes(graph.Nodes); newGraph = Postman.PairingOddVertices(graph, oddNodes); } var eulerianPath = Postman.FindEulerianPath(newGraph); System.Console.WriteLine("\n"); MyPrinter.HeaderPrint("Chinese postman problem"); MyPrinter.PrintMatrix(matrix, "Matrix instance\n"); // MyPrinter.PrintGraph(graph, "Graph instance: Edges"); MyPrinter.ShowAdditionalEdges(graph, newGraph); MyPrinter.PrintNodes(graph.Nodes, newGraph.Nodes); MyPrinter.PrintPath(eulerianPath.ToArray()); }