コード例 #1
0
ファイル: Actions.cs プロジェクト: nestorselin/lbs
        public static void GetBoruvka()
        {
            var graph         = Initializing.CreateGraph(@"./_First.txt");
            var graphToReturn = BoruvkasAlgorithm.BoruvkaSolve(graph);

            System.Console.WriteLine("\n");
            ConsolePrint.HeaderPrint("Boruvka's method minimum spanning tree");
            ConsolePrint.PrintGraph(graph);
            ConsolePrint.PrintGraph(graphToReturn, "New Graph Edges");
        }
コード例 #2
0
        public static void StartingMenu()
        {
            while (true)
            {
                ConsolePrint.HeaderPrint("\"Discrete models\"");
                ConsolePrint.HeaderPrint("Press number of laba to show solving");

                GetActions();

                SelectMenuAction(Console.ReadLine());
            }
        }
コード例 #3
0
ファイル: Actions.cs プロジェクト: nestorselin/lbs
        public static void GetSalesman()
        {
            var graph  = Initializing.CreateGraph(@"./_Third.txt");
            var matrix = Initializing.CreateMatrix(@"./_Third.txt");

            BnB_matrix brunchAndBound = new BnB_matrix();

            var edges = brunchAndBound.BranchAndBound(matrix);

            System.Console.WriteLine("\n");
            ConsolePrint.HeaderPrint("Salesman problem");
            ConsolePrint.PrintGraph(graph);
            ConsolePrint.PrintPath(edges);
        }
コード例 #4
0
ファイル: Actions.cs プロジェクト: nestorselin/lbs
        public static void GetMaxFlowByFF()
        {
            var graph = Initializing.CreateGraph(@"./_Fourth.txt");

            FlowCalc flowCalc = new FlowCalc(graph);
            var      flow     = flowCalc.FindMaximumFlow();

            var maxFlow = flow.Where(e => e.Edge.Destination == graph.Nodes.Last().Id).Sum(x => x.Flow);

            System.Console.WriteLine("\n");
            ConsolePrint.HeaderPrint("Max flow");
            ConsolePrint.PrintGraph(graph);
            ConsolePrint.PrintFlow(graph.Edges, flow.ToArray());
            System.Console.WriteLine($"\t\tMAXIMUM FLOW = {maxFlow}\n\n");
        }
コード例 #5
0
ファイル: Actions.cs プロジェクト: nestorselin/lbs
        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());
        }