Exemple #1
0
        private void Push(FlowEdge edge, int v, int other)
        {
            double flow = Math.Min(edge.ResidualCapacityTo(other), excess[v]);

            excess[v]     -= flow;
            excess[other] += flow;
            edge.AddFlow(flow, other);
        }
Exemple #2
0
        private void Push(FlowEdge e, int from)
        {
            //вычислляем максимальный объем потока, который можно протолкнуть через ребро
            var f = Math.Min(excess[from], e.ResidualCapacityTo(e.Other(from)));

            //если ребро допустимо
            if (height[from] == height[e.Other(from)] + 1 && f > 0)
            {
                //проталкиваем поток в ребро
                e.AddFlow(f, e.Other(from));
                //обновляем избыток в узлах ребра
                excess[e.Other(from)] += f;
                excess[from]          -= f;
                //добавляем в Bucket узел, в сторону которого протолкнули поток
                if (e.Other(from) != graph.Source)
                {
                    Enq(e.Other(from));
                }
            }
        }