Exemple #1
0
        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);
        }
        public async Task <IActionResult> GetSalesman()
        {
            var graph  = Initializing.CreateGraph(@"../Graph/_SalesmanProblem.txt");
            var matrix = Initializing.CreateMatrix(@"../Graph/_SalesmanProblem.txt");

            BnB_matrix brunchAndBound = new BnB_matrix();

            var edges         = brunchAndBound.BranchAndBound(matrix);
            var graphToReturn = (Graph)graph.Clone();

            graphToReturn.EdgesCount = edges.Length;

            graphToReturn.Edges = edges;

            List <Graph> listGraph = new List <Graph>
            {
                graph,
                graphToReturn
            };

            return(Ok(listGraph));
        }
        public async Task <IActionResult> GetSalesman()
        {
            var graph  = Initializing.CreateGraph(@"../Graph/_SalesmanProblem.txt");
            var matrix = Initializing.CreateMatrix(@"../Graph/_SalesmanProblem.txt");

            BnB_matrix brunchAndBound = new BnB_matrix();

            var edges         = brunchAndBound.BranchAndBound(matrix);
            var graphToReturn = (Graph)graph.Clone();

            // foreach (var item in edges)
            // {
            //     if (graphToReturn.Edges.Any(x => x.Source == item.Source && x.Destination == item.Destination))
            //     {
            //        continue;
            //     }
            //     else if (graphToReturn.Edges.Any(x => x.Destination == item.Source && x.Source == item.Destination))
            //     {
            //        int temp = 0;
            //        temp = item.Source;
            //        item.Source = item.Destination;
            //        item.Destination = temp;
            //     }
            // }
            graphToReturn.EdgesCount = edges.Length;

            graphToReturn.Edges = edges;

            List <Graph> listGraph = new List <Graph>
            {
                graph,
                graphToReturn
            };

            return(Ok(listGraph));
        }