示例#1
0
        public int OnMinCostFlowCall()
        {
            int maxFlow = OnMaxFlowCall();

            (int minCostFlow, int cost, var edgesSaturation) = FlowAlgorithms.MinCostFlow(
                _graphMatrix,
                0,
                Vertices - 1,
                maxFlow * 2 / 3);
            string edges = GetFlowEdgesString(edgesSaturation);

            _view.AppendToLog($"{_logEntryNumber++}: Max Flow found:" +
                              Environment.NewLine +
                              $"Max Flow: {maxFlow}" +
                              Environment.NewLine +
                              $"2 * Max Flow / 3: {2 * maxFlow / 3}" +
                              Environment.NewLine +
                              $"Found Flow: {minCostFlow}" +
                              Environment.NewLine +
                              $"Found Flow cost: {cost}" +
                              Environment.NewLine +
                              "Edges:" +
                              Environment.NewLine +
                              edges +
                              Environment.NewLine + Environment.NewLine);

            return(minCostFlow);
        }
示例#2
0
        public int OnMaxFlowCall()
        {
            (int maxFlow, var edgesSaturation) =
                FlowAlgorithms.MaxFlow(_graphMatrix, 0, Vertices - 1);
            string edges = GetFlowEdgesString(edgesSaturation);

            _view.AppendToLog($"{_logEntryNumber++}: Max Flow found:" +
                              Environment.NewLine +
                              $"Max Flow: {maxFlow}" +
                              Environment.NewLine +
                              "Edges: " +
                              Environment.NewLine +
                              edges +
                              Environment.NewLine + Environment.NewLine);
            return(maxFlow);
        }
示例#3
0
        public void OnCreateFlowNetworkCall()
        {
            FlowAlgorithms.TurnIntoFlowNetwork(_graphMatrix);
            _flowNetworkGenerated = true;

            _view.AppendToLog($"{_logEntryNumber++}: Flow Network Generated:" +
                              Environment.NewLine +
                              "Adjacency Matrix: " +
                              Environment.NewLine +
                              MatrixPrinter.GetMatrix(_graphMatrix.GetAdjacencyMatrix()) +
                              "Weight Matrix: " +
                              Environment.NewLine +
                              MatrixPrinter.GetMatrix(_graphMatrix.GetWeightMatrix()) +
                              "Capacities Matrix: " +
                              Environment.NewLine +
                              MatrixPrinter.GetMatrix(_graphMatrix.GetCapacitiesMatrix()) +
                              Environment.NewLine);

            _graphMatrix.OutputToFile();
            UpdateViewGraphImage();
        }