a faster strongly polynomial minimum cost flow algorithm james b. orlin

A FASTER STRONGLY POLYNOMIAL
MINIMUM COST FLOW ALGORITHM
JAMES B. ORLIN
Aviv Eisenschtat
6/5/2013
Introduction

Developed in 1989

Based on the Edmonds & Karp scaling algorithm

Fastest strongly polynomial algorithm for min-cost flow

Fairly simple and intuitive

Work best for networks with small number of
capacitated arcs
Overview

Recap




RHS-Scaling Algorithm
Contractions






Min Cost flow
Dual Problem
Justification
Difficulties
Algorithm Presentation
Network Expension
Capacitated to Uncapacitated reduction
Improvement for the shortest path algorithm
Min Cost Flow

𝐺 = (𝑁, 𝐴) is a directed graph

Cost 𝑐𝑖𝑗 ≥ 0 for every arc 𝑖, 𝑗

𝑚′ capacitated arc with capacity 𝑢𝑖𝑗

𝑏(𝑖) – supply (or demand) on node 𝑖
Dual minimum cost flow - Reminder
Prime:
Minimize
𝑖,𝑗 ∈𝐴 𝑐𝑖𝑗
𝑥𝑖𝑗
Subject to
𝑥𝑖𝑗 −
𝑗: 𝑖,𝑗 ∈𝐴
𝑥𝑗𝑖 = 𝑏 𝑖 𝑓𝑜𝑟 𝑎𝑙𝑙 𝑖 ∈ 𝐴
𝑗: 𝑖,𝑗 ∈𝐴
𝑥𝑖𝑗 ≥ 0 𝑓𝑜𝑟 𝑎𝑙𝑙 𝑖, 𝑗 ∈ 𝐴
Dual:
Maximize
𝑖∈𝑁 𝑏
𝑖 𝜋(𝑖)
Subject to
𝜋 𝑖 − 𝜋 𝑗 ≤ 𝑐𝑖𝑗 𝑓𝑜𝑟 𝑎𝑙𝑙 𝑖, 𝑗 ∈ 𝐴
RHS-Scaling Outline

Assume uncapacitated network and integral costs and supplies

Maintain a scaling factor ∆ which is a power of 2

Push ∆ flow units for node with excess larger then ∆ to nodes with excess
lower then −∆

Push flow only on shortest path

Continue until there are no nodes to push from or to push to

Decrease Δ by factor 2 and repeat

Stop when the network is balanced (∆< 1)
Definitions

S ∆ = 𝑖: 𝑒 𝑖 ≥ ∆ - nodes with excess at least 

T ∆ = 𝑖: 𝑒 𝑖 ≤ −∆ - nodes with deficit at least 

∆-Optimal – A pseudo flow x and potentials π are ∆Optimal if (x, π) satisfies the optimality conditions
and either S(∆) = ∅ or T(∆) = ∅.
∆ is larger then the
maximal demand
Continue as long as
the flow is not ∆optimal
Compute shortest
path (with reduced
costs as lengths)
Correctness - Intuition

For ∆= 2 𝑙𝑜𝑔2 𝑈 > 𝑈, x = 0 and π = 0 the flow is ∆-Optimal

Each iteration we replace ∆ with

At the end of every scaling phase we obtain a ∆-Optimal flow

This is achieved by finding at most n shortest paths

When ∆< 1 x is balanced and optimal
∆
2
RHS Scaling - Correctness
At every step the flow and residual capacity is an integral
multiple of ∆
Inductively
The algorithm maintains a ∆-Optimal flow x w.r.t π
 Initially 𝑥 = 0, 𝑢𝑖𝑗 = ∞ and it’s clear



Suppose we are in the ∆-Scaling phase
augmentation modifies the residual capacities of arcs by 0 or ∆
units and, consequently, preserves the induction hypothesis.
Reducing the scale factor of ∆ to ∆/2 also maintains the
invariant
RHS Scaling – Correctness cont.

during an augmentation, Δ units of flow can be sent on any
path P with positive residual capacity.

Sending flow down a shortest path does not break optimality

The pseudo flow after each scaling phase still satisfies the
optimality condition.

The algorithm terminates when all nodes are balanced

Clearly, this flow must be optimum.
RHS Scaling – Notations

Node i is active if 𝑒(𝑖) ≥ ∆ and is inactive if 𝑒(𝑖)
< ∆.

Node i is regenerated if it was inactive in the
previous scaling phase and it is active in the current
scaling phase

It is clear that for each regenerated node:
∆ ≤ 𝑒 𝑖 < 2∆
Complexity

We start with ∆= 2 𝑙𝑜𝑔𝑈 , U = max{b i , i ∈ 𝑁}
∆
2

At each phase ∆←

Clearly there are 𝑂 𝑙𝑜𝑔𝑈 scaling phases.

We will now prove that the algorithm can find at
most n augmenting paths in any scaling phase.
RHS Scaling – Complexity cont.


The number of augmentations in a scaling phase is at most the
number of nodes that are regenerated at the beginning of the
phase
Proof:
 At the beginning of the Δ scaling phase either S(2∆) = ∅ or
T(2∆) = ∅. We will assume that S(2∆) = ∅
 Every node in S(∆) is a regenerated node.
 𝑒 𝑖 < 2∆ for each 𝑖 ∈ 𝑆 ∆
 Augmentation send ∆ units of flow, thus after an
augmentation 𝑒 𝑖 < ∆⇒ 𝑖 ∉ 𝑆(∆)
 Augmentation terminated at a sink node, thus it cannot
make active nodes
 There are at most 𝑆 ∆ = 𝑂(𝑛) augmentations
RHS Scaling – Complexity cont.

There are 𝑂 𝑙𝑜𝑔𝑈 scaling phases

Number of augmentations is bounded by the number of
regenerations in each phase

The RHS algorithm runs in 𝑂 𝑛𝑙𝑜𝑔𝑈 ∙ 𝑆(𝑛, 𝑚)

𝑆(𝑛, 𝑚) – running time of the shortest path algorithm

The next phase is to make this algorithm Strongly Polynomial
Contractions - Intuition

We will try to find arcs with flow so large in the Δ-Scaling
phase that they must have a positive flow in the subsequent
scaling phases

An arcs with a sufficiently large flow can contracted into a
single node

Contraction does not effect optimality

Optimal flow found on the contracted network can be
transformed into an optimal flow in the original network
Contraction - Motivation

During the algorithm a node cannot be uncontracted

The number of contractions is 𝑂(𝑛)

If we can show that after “few” scaling phases we
contract a node we can bound the number phases by a
function of 𝑛
Strongly Feasible Arc

Recall there are at most 𝑛 augmentation in a Δ-Scaling
phase

A flow in any arc can change by at most ∆𝑛 units

The total change for any arc is:
𝑛 ∆ + ∆ 2 + ∆ 4 + ∆ 8 + ⋯ + 1 = 2𝑛∆

If an arc exceeds 2n∆ units of flow we can contract it

We will refer to that arc as strongly feasible arc
Contraction Method

An arc (k,l) with flow larger than 2𝑛∆ can be contracted into a
single node p letting:





𝑏 𝑝 =𝑏 𝑘 +𝑏 𝑙
𝑒 𝑝 =𝑒 𝑘 +𝑒 𝑙
Replacing each arc (k,i) and (l,i) with (p,i)
Replacing each arc (j,k) and (j,l) with (j,p)
Costs remain the same
𝑖
𝑏(𝑖)
𝑒(𝑖)
𝑝
𝑏(𝑗)
𝑗 𝑒(𝑗)
𝑏 𝑝 = 𝑏 𝑖 + 𝑏(𝑗)
𝑒 𝑝 = 𝑒 𝑖 + 𝑒(𝑗)
Justifying Contractions Cont.

Lemma 1: If 𝑥 is an optimal flow of the minimum cost
flow problem with costs 𝑐𝑖𝑗 for each arc 𝑖, 𝑗 ∈ 𝐴. Then
it is also the optimal flow for the minimum cost flow
′
𝜋
problem with the cost of each arc 𝑖, 𝑗 ∈ 𝐴 as 𝑐𝑖𝑗
= 𝑐𝑖𝑗
= 𝑐𝑖𝑗 − 𝜋 𝑖 + 𝜋 𝑗 for any set of node potentials 𝜋

Otherwise there would be a negative cycle in the residual
network associated with 𝑥 in the original problem
Justifying Contractions

Lemma 2: Suppose 𝑥𝑙𝑘 > 0 in an optimal solution, then
the reduced cost of (𝑘, 𝑙) is zero for every optimum
node potentials.

It can be proved that if 𝑥 satisfies the complementary
slackness for some optimal node potential then it satisfies
the complementary slackness for all optimal node
potential
Justifying Contractions Cont.

Let 𝑃 denote the min-cost flow problem

During the RHS-Scaling algorithm we realize that arc (𝑘, 𝑙) is
strongly feasible, suppose 𝜋 are the potentials found so far

𝜋
From the optimality condition 𝑐𝑘𝑙
= 𝑐𝑘𝑙 − 𝜋 𝑘 + 𝜋 𝑙 = 0

Consider a problem 𝑃′ created by replacing the costs with
the residual costs, thus for each arc (𝑖, 𝑗)
′
𝑐𝑖𝑗
= 𝑐𝑖𝑗 − 𝜋 𝑖 + 𝜋(𝑗)

′
𝑐𝑘𝑙
=0
Justifying Contractions Cont.

𝑃 and 𝑃′ have the same optimal solutions, thus (𝑙, 𝑘) have
a positive flow in the optimal solution of 𝑃′

Suppose 𝜋 ′ is the optimal set of node potentials for 𝑃′

𝜋
′
𝑐𝑘𝑙
= 𝑐𝑘𝑙
− 𝜋 ′ 𝑘 + 𝜋 ′ 𝑙 = 𝜋 ′ 𝑙 − 𝜋 ′ 𝑘 = 0 (from
lemma 2)

𝜋′ 𝑙 = 𝜋′ 𝑘
′
Justifying Contractions Cont.

Upon finding a strongly feasible arc (𝑘, 𝑙) we can update the
problem and ensure that the potential of 𝑘 and 𝑙 are identical

If we solve the dual problem minimum cost with the addition
constraint of 𝜋 ′ 𝑘 = 𝜋 ′ 𝑙 and not affect the optimality of
the dual

We can solve the problem by replacing 𝜋 𝑙 and 𝜋(𝑘) with
𝜋(𝑝) in the linear program and lower the number of variables

Essentially this is contraction of 𝑙 and 𝑘
Next Step

By now we are convinced that contraction does not effect
optimality of the dual problem

Contraction lowers the complexity of the problem and thus
the number of contractions is bounded by 𝑛

Next we will see that there is a strongly feasible arc after
“sufficiently small” number of scaling phases

We will charge a sequence of scaling phases to a contracted
node
Nearing strongly polynomial

We denote the contracted network by 𝐺 = (𝑁, 𝐴)

Lemma: After termination of a scaling phase, if for
some node 𝑖, 𝑏(𝑖) > 5𝑛2 ∆ then there is an arc (𝑖, 𝑗)
or (𝑗, 𝑖) such that the flow on the arc is at least 3𝑛∆
Nearing strongly polynomial

Proof: Suppose we are at the beginning of the ∆-Scaling phase.

We know that either 𝑆 2∆ = ∅ or 𝑇 2∆ = ∅. Thus the
total deficit and excess is bounded by 2𝑛∆.
This implies that for every node 𝑖, 𝑒(𝑖) < 2𝑛∆
Suppose 𝑏 𝑖 > 0 (𝑏 𝑖 < 0 is proved similarly)
The net flow going out of 𝑖 is (𝑏 𝑖 − 𝑒(𝑖))


(𝑏 𝑖 − 𝑒(𝑖))
𝑖i
Nearing strongly polynomial

There are at mode 𝑛 arc emanating from 𝑖

At least one arc have flow grater then (𝑏 𝑖 − 𝑒 𝑖 ) 𝑛

𝑒 𝑖 < 2𝑛∆ and 𝑏 𝑖 > 5𝑛2 ∆

(𝑏 𝑖 − 𝑒 𝑖 ) 𝑛 ≥ 5𝑛2 ∆ − 2𝑛∆ 𝑛 ≥ 3𝑛∆

This implies that the arc is strongly feasible
Nearing strongly polynomial

All node start with 𝑒 𝑖 = 𝑏 𝑖

Once 𝑏(𝑖) > ∆ for some node 𝑖 it will be contracted
after log 5𝑛2 ∆ = log(𝑛) phases

If we eliminate “Empty” phases where 𝑏(𝑖) ≤ ∆ for
each node 𝑖 we can charge a sequence of scaling phases
to a contraction and bound the number of phases by
𝑂(𝑛𝑙𝑜𝑔𝑛)

This almost leads into a strongly polynomial complexity
Nearing strongly polynomial



Why almost?
There is a difficulty resulting from the contraction, this is
illustrated in the next example
Assume M is very large, arc costs a 0 and the initial flow is 0.
8M-1
1
0
-8M-1
2
0
3
8M+1
0
4
-8M+1
Nearing strongly polynomial



Why almost?
There is a difficulty resulting from the contraction, this is
illustrated in the next example
Assume M is very large, arc costs a 0 and the initial flow is 0.
8M-1
1
8M
-1
2
8M
8𝑀-Scaling Phase
3
1
0
4
-8M+1
Nearing strongly polynomial



Why almost?
There is a difficulty resulting from the contraction, this is
illustrated in the next example
Assume M is very large, arc costs a 0 and the initial flow is 0.
4M-1
1
8M
-1
2
4M
4𝑀-Scaling Phase
3
1
4M
4
-4M+1
Nearing strongly polynomial



Why almost?
There is a difficulty resulting from the contraction, this is
illustrated in the next example
Assume M is very large, arc costs a 0 and the initial flow is 0.
2M-1
1
8M
-1
2
2M
2𝑀-Scaling Phase
3
1
6M
4
-2M+1
Nearing strongly polynomial



Why almost?
There is a difficulty resulting from the contraction, this is
illustrated in the next example
Assume M is very large, arc costs a 0 and the initial flow is 0.
M-1
1
8M
-1
2
M
𝑀-Scaling Phase
3
1
7M
4
-M+1
Nearing strongly polynomial



Why almost?
There is a difficulty resulting from the contraction, this is
illustrated in the next example
Assume M is very large, arc costs a 0 and the initial flow is 0.
Contraction
M-2
A
M
B
-M+2
• b(A) = -2
• b(B) = 2
It will take O(logM) scaling phases
until the arc is strongly feasible
and the algorithm terminates.
Summarize





It is possible to create contracted nodes in which the
excess/deficit is comparable to ∆ and is much larger
then the supply/demand at the node
Node can be regenerated a large number of times
Occurs infrequently
When 𝑒 𝑘 = ∆ − 𝜀 and 𝑏 𝑘 = −𝜀 for very small
positive 𝜀
When e 𝑘 = −∆ + 𝜀 and b 𝑘 = 𝜀 for very small
positive 𝜀
Solution

We modify the augmentation rules slightly

S ∆ = 𝑖: 𝑒 𝑖 ≥ 𝛼∆ 𝑠. 𝑡. 1 2 < 𝛼 < 1

T ∆ = 𝑖: 𝑒 𝑖 ≤ −𝛼∆ 𝑠. 𝑡. 1 2 < 𝛼 < 1

This way if a “bad” contraction occurred then we empty
the node fast
The Algorithm

RHS-Scaling algorithm with the following
modifications:





Contract an arc when it becomes strongly feasible
Allow augmentations from nodes with 𝑒 𝑖 ≥ 𝛼∆ to nodes
with 𝑒 𝑗 ≤ −𝛼∆, 1 < 𝛼 < 1 2 (If 𝛼 = 1 the algorithm is not
strongly polynomial)
We no longer require ∆ to be a power of two and no longer
require ∆ to be divided by 2
The strongly polynomial algorithm solves the dual minimum
cost flow.
When ∆ is decreased by factor larger then 2 we call that
step complete regeneration
Start with initial ∆ equals to
max excess
Contract nodes connected to
strongly feasible arc
Perform RHS Scaling on the
contracted network
Eliminates the possibility of
“passive” phases where nothing
can happened
Correctness


Lemma: At every step of the algorithm the flow and residual
capacity of each arc is an integral multiple of ∆
Proof: By induction on the number of augmentations,
contractions and scale factor adjustments.
The initial is 0 and capacities ∞, the lemma holds.
 Each augmentation carries ∆ units of flow and preserve the
hypothesis
 Contraction doesn’t effect the flow of the remaining arcs
 ∆ can change into ∆ 2 which preserve the hypothesis or it
changes into 𝑚𝑎𝑥 𝑒 𝑖 : 𝑖 ∈ 𝑁 , this occurs when all arc flow
is 0.
Correctness cont.




Each augmentation can send ∆ units of flow down a
path 𝑃
The algorithm always maintains a pseudo flow that
satisfies the optimality condition
Terminates when the network is balanced or it is
contracted into a single node
Thus, terminates with a optimal flow in the
contracted network
We will show later on how to produce an optimal flow
in the original network
Complexity

Steps:

Step 1: Bound the number of augmentation to the number of
contractions plus the number of regenerations

Step 2: Bound the number of regenerations for a single node
until contraction

Step 3: Bound the number of scaling phases
Complexity – Step 1
Lemma: The number of augmentations during a ∆-Scaling phase is
bounded by the number of regenerated nodes plus the number
of contracted node in that phase
Proof: Let ∆′ be the scaling factor of the previous scaling phase,
′
∆
thus ∆ ≤ 2 and at the end of the previous scaling phase S ∆′
= ∅ or T ∆′ = ∅, We consider the case where S ∆′ = ∅ (the
other case is similar)
Complexity – Step 1

Potential function: Φ =

Augmentation sends ∆ units of flow from a node in S hence Φ
decrease by 1.

Thus, Number of Augmentations is bounded by:
𝑖∈𝑆
𝑒(𝑖) 𝛼∆
Φ𝑠𝑡𝑎𝑟𝑡 − Φ𝑒𝑛𝑑 + 𝐼𝑛𝑐𝑟𝑒𝑎𝑠𝑒

The initial value Φ𝑠𝑡𝑎𝑟𝑡 ≤ 𝑆(∆) thus it bounded by the number of
regenerated nodes, for every node 𝑖 ∈ 𝑆 ∆ :

If ∆=

If ∆<
∆′
2
∆′
2
then 𝑒 𝑖 < 2𝛼∆ and
then 𝑒 𝑖 ≤ ∆ and
𝑒 𝑖
𝛼∆
𝑒 𝑖
𝛼∆
≤
<2
1
𝛼
≤1
Complexity – Step 1 cont.

The effect of contraction 𝑖 and 𝑗:

If 𝛼∆≤ 𝑒 𝑖 < 2𝛼∆ and 𝛼∆≤ 𝑒 𝑗 < 2𝛼∆ then:


≤
𝑒(𝑖)
𝛼∆
+
𝑒(𝑗)
𝛼∆
+1
If 𝑒 𝑖 < 𝛼∆ or 𝑒 𝑗 < 𝛼∆



𝑒 𝑖 +𝑒(𝑗)
𝛼∆
Assuming 𝑒 𝑗 < 𝛼∆
𝑒 𝑖 +𝑒(𝑗)
𝛼∆
≤
𝑒 𝑖
𝛼∆
+
𝑒 𝑗
𝛼∆
+1≤
𝑒 𝑖
𝛼∆
+1
Contraction can increase Φ by at most 1
Complexity – Step 1 cont.




Φ𝑒𝑛𝑑 ≥ 0
Φ𝑠𝑡𝑎𝑟𝑡 < number of regenerations
𝐼𝑛𝑐𝑟𝑒𝑎𝑠𝑒 ≤ number of contractions
Thus, Number of Augmentations is bounded by the
number of regenerations plus the number of contractions
Complexity – Step 2

Lemma: In the ∆-Scaling phase if 𝑥𝑖𝑗 ≥ 3𝑛∆ for some
arc (𝑖, 𝑗) in 𝐴, then it is strongly feasible

Proof: We have seen that with no contraction 𝑥𝑖𝑗
≥ 2𝑛∆ is enough.
Contraction adds at most one more augmentation
(Step 1) and there are at most 𝑛 − 1 contractions.
Thus the total flow change on any arc is at most 3𝑛∆

Complexity – Step 2

Lemma: During ∆-Scaling phase 𝑒 𝑖 = 𝑏 𝑖 + ∆𝑤
for any integral number 𝑤

Proof: The value of 𝑒(𝑖) is 𝑏(𝑖) minus the flow across
the cut 𝑖, 𝑁 − 𝑖 , each arc flow is a multiple of ∆.
Hence the lemma holds
𝑖, 𝑁 − 𝑖
𝑖i
Complexity – Step 2

Lemma: The first time a node i is regenerated, it satisfies 𝑒(𝑖)
≤ 2𝛼 𝑏(𝑖) (2 − 2𝛼)

Proof: suppose that node i was regenerated for the first time
at the beginning of ∆-Scaling phase. In case of complete
regeneration the flow is zero and 𝑒 𝑖 = 𝑏 𝑖 ;
Otherwise all arc flows are integral multiple of 2∆.
Consider first the case that 𝑒 𝑖 > 0, we know that:


𝛼∆ ≤ 𝑒 𝑖 < 2𝛼∆
𝑒 𝑖 = 𝑏 𝑖 + 2∆ 𝑤
The case when 𝑒 𝑖 < 0 can be proved analogously
Complexity – Step 2

Lemma: The first time a node i is regenerated, it satisfies 𝑒(𝑖)
≤ 2𝛼 𝑏(𝑖) (2 − 2𝛼)

Proof:



If 𝑤 = 0 then 𝑒 𝑖 = 𝑏 𝑖 and the lemma follows
If 𝑤 ≥ 1 then 𝑒 𝑖 ≥ 𝑏 𝑖 + 2∆ ⇒ 𝑏 𝑖 ≤ 𝑒 𝑖 − 2∆
⇒ 𝑏 𝑖 < 2𝛼 − 2 ∆
from 𝑒 𝑖 < 2𝛼∆
⇒ 𝑏 𝑖 > 2 − 2𝛼 ∆
from 𝛼 < 1, 𝑏 𝑖 < 0
⇒ 𝑒 𝑖 < 2𝛼 𝑏(𝑘) (2 − 2𝛼)
from ∆ > 𝑒(𝑖) 2𝛼
𝑤 ≤ −1 then 0 ≤ 𝑒 𝑖 ≤ 𝑏 𝑖 − 2∆ ≤ 𝑏 𝑖 ≤ 2𝛼𝑏(𝑖)/(2 − 2𝛼)
Complexity – Step 2

Step 2: Each node is regenerated 𝑂(log 𝑛 ) times until it contracts

Proof: Suppose node 𝑖 is regenerated for the first time at phase
∆′ , 𝛼 ∗ = 2𝛼 (2 − 2𝛼)

𝛼∆′ ≤ 𝑒 𝑖

𝛼∆′ 𝛼 ∗ ≤ 𝑏 𝑖



After 𝑙𝑜𝑔
𝑏 𝑖
≥
𝛼∆′
𝛼∗
≤ 𝑏 𝑖 𝛼∗
5𝑛2
𝛼
≥
∙
𝛼∗
= 𝑂(log 𝑛 ) scaling phases ∆≤
5𝛼∗ 𝑛2 𝛼∆
𝛼𝛼 ∗
𝛼 ∗ ∆′
.
5𝛼𝑛2
≥ 5𝑛2 ∆
Thus there exists a strongly feasible arc emanating from 𝑖. The node
is then contracted and not regenerated again.
Complexity – Steps 1 & 2

Summarizing the two steps:

Augmentations ≤ Regenerations + Contractions

Contractions ≤ 𝑛 − 1

Regenerations ≤ 𝑛 − 1 𝑂 log 𝑛

Thus, Number of augmentations = 𝑂(𝑛𝑙𝑜𝑔 𝑛 )
= 𝑂(𝑛𝑙𝑜𝑔 𝑛 )
Complexity - Step 3

The algorithm preforms 𝑂(𝑛𝑙𝑜𝑔 𝑛 ) scaling phases

We have seen that the number of scaling phases in
which an augmentation occurs is bounded by
O(𝑛𝑙𝑜𝑔 𝑛 )

We will see next a bound on the number of scaling
phases in which no augmentation occurs
Complexity - Step 3 cont.

Case 1: suppose there exists a node i which 𝑒(𝑖)
> ∆ 5𝑛2 .




In log 5𝑛2 phases 𝑒(𝑖) ≥ ∆ and it is regenerated
In O(log 𝑛 ) phases it is contracted
We can charge a sequence of this type of phases to a
contraction
Overall this can occur O(𝑛𝑙𝑜𝑔 𝑛 ) times
Complexity - Step 3 cont.

Case 2: 𝑒(𝑖) ≤ ∆ 5𝑛2 for each node i and all arcs in
the contracted network has 0 flow.




∆ = 𝑚𝑎𝑥 𝑒 𝑖 : 𝑖 ∈ 𝑁
The node with maximum excess is regenerated
In O(log 𝑛 ) phases it is contracted
This case can occur at most O(𝑛𝑙𝑜𝑔 𝑛 ) times
Complexity - Step 3 cont.

Case 3: 𝑒(𝑖) ≤ ∆ 5𝑛2 for each node 𝑖 and there is
some arc (𝑙, 𝑘) with positive flow






𝑥𝑖𝑘 ≥ ∆
In the next log 5𝑛2 phases 𝑥𝑖𝑘 is unchanged
In log(5𝑛2 ) phases ∆′ ≤ ∆ 5𝑛2
𝑥𝑖𝑘 ≥ 5𝑛2 ∆′ ≥ 3𝑛∆′
Arc (𝑙, 𝑘) is strongly feasible and it is contracted.
This case can occur O(𝑛𝑙𝑜𝑔(𝑛)) times
Complexity - Step 3 cont.

We have 𝑂 𝑛𝑙𝑜𝑔 𝑛
augmenting scaling phases

We have 𝑂 𝑛𝑙𝑜𝑔 𝑛
non augmenting scaling phases

The total number of scaling phases is 𝑂 𝑛𝑙𝑜𝑔 𝑛
Complexity – The end



Theorem: The strongly polynomial algorithm
determines the minimum cost flow in the contracted
network in 𝑂( 𝑛𝑙𝑜𝑔 𝑛 𝑆 𝑛, 𝑚 )
Proof:
Time spend in a scaling phase





Reducing the scale factor - 𝑂 𝑚
Finding strongly feasible arcs - 𝑂 𝑚
Building 𝑆(∆) and 𝑇 ∆ - 𝑂 𝑛
Total of (𝑛 ∙ 𝑚𝑙𝑜𝑔(𝑛))
Number of augmentations 𝑂 𝑛𝑙𝑜𝑔 𝑛
𝑂 𝑛𝑙𝑜𝑔 𝑛 𝑆(𝑛, 𝑚 )
⇒Total of
Obtaining Optimal Flow

We so far produced optimal node potential in a
contracted network 𝐺

To obtain optimal flow in 𝐺 we need to:


uncontracting the network and produce node potential
convert the node potentials into optimum flow
Network Expansion


Reminder:The contraction operation contained two
stages

Replacing 𝑐𝑖𝑗 with 𝑐𝑖𝑗 − 𝜋 𝑖 + 𝜋(𝑗)

Contract nodes k and l into p
We expand the network in the reverse order it was
contracted
Network Expansion



Suppose 𝜋 ′ is the optimal node potentials
We iterate the contracted nodes in a reverse order
they ware created
The expansion of a node 𝑝 consists of:



Set 𝜋 ′ 𝑙 = 𝜋 ′ 𝑘 = 𝜋 ′ 𝑝
Update 𝜋 ′ 𝑖 = 𝜋 ′ 𝑖 + 𝜋 𝑖 , where 𝜋(𝑖) was the node
potential when 𝑙 and 𝑘 were contracted.
To show what is behind stage 2 we need to prove the
following lemma
Network Expansion


Lemma: Let 𝑃 be a problem with arc costs 𝑐𝑖𝑗 and 𝑃′
be the same problem with arc costs 𝑐𝑖𝑗 − 𝜋 𝑖 − 𝜋(𝑗)
and node potentials 𝜋 ′ , then the same solution
satisfies the same conditions with arc costs 𝑐𝑖𝑗 and
node potentials 𝜋 + 𝜋 ′
Proof: Suppose 𝑥 satisfies the optimality condition
with arc costs 𝑐𝑖𝑗 − 𝜋 𝑖 − 𝜋(𝑗) and potentials 𝜋 ′
𝑐𝑖𝑗 − 𝜋 𝑖 + 𝜋 𝑗 − 𝜋 ′ 𝑖 + 𝜋 ′ 𝑗 ≥ 0
⇒ 𝑐𝑖𝑗 − (𝜋 𝑖 + 𝜋 ′ 𝑖 ) + (𝜋 𝑗 + 𝜋 ′ 𝑗 ) ≥ 0
Obtaining optimal flow





We will use the optimum node potential to produce optimum
flow by solving maximum flow problem
𝜋 ∗ optimum node potentials of a min-cost problem
We define reduced costs as 𝑐𝑖𝑗 − 𝜋 ∗ 𝑖 + 𝜋 ∗ 𝑗
Remove all arc with non-zero reduced costs
Find a nonnegative flow in the subnetwork:




𝜋
𝐺 ° = 𝑁, 𝐴° ; 𝐴° = { 𝑖, 𝑗 ∈ 𝐴: 𝑐𝑖𝑗
= 0}
Add a super source 𝑠 ∗ connected to node i with 𝑏 𝑖 > 0
with an arc (𝑠 ∗ , 𝑖) with capacity 𝑏(𝑖)
Add a super sink 𝑡 ∗ connected to node i with 𝑏 𝑖 < 0 with
an arc (𝑖, 𝑡 ∗ ) with capacity 𝑏 𝑖
Solve a maximum flow from 𝑠 ∗ to 𝑡 ∗
Capacitated Problem

The algorithm described solves the uncapacitated
problem

How can we solve the capacitated problem?

We will transform the capacitated problem into
uncapacitated problem with
Capacitated Problem


We will replace each capacitated arc (𝑖, 𝑗) by an
additional node 𝑘 and two arcs 𝑖, 𝑘 and 𝑗, 𝑘
We denote the nodes created this way as 𝑁2
𝑏(𝑖)
𝑏(𝑖)
𝑖
𝑖
−𝑢𝑖𝑗
′
(𝑥
(𝑐𝑖𝑗 , 𝑢𝑖𝑗 )
𝑖𝑗 )
𝑗
𝑏(𝑗)
(𝑐𝑖𝑗 , ∞)
𝑘
′
𝑥𝑗𝑘 = 𝑢𝑖𝑗 − 𝑥𝑖𝑗
′
𝑥𝑖𝑘 = 𝑥𝑖𝑗
𝑗
𝑏 𝑗 + 𝑢𝑖𝑗
(0, ∞)
Capacitated Problem

In the transformation we added a node for each
capacitated arc, suppose there are 𝑚′ capacitated
arcs and 𝑚 uncapacitated arcs then:


𝑁 = 𝑛 + 𝑚′
The algorithm will solve the problem in 𝑂( 𝑛 + 𝑚′ log(𝑛)
∙ 𝑆(𝑛 + 𝑚′ , 𝑚 + 𝑚′ ))
Summerize

So far the algorithm presented solved the minimum
cost flow




In 𝑂(𝑛𝑙𝑜𝑔 𝑛 𝑆 𝑛, 𝑚 ) for uncapacitated problems
In 𝑂( 𝑛 + 𝑚′ log 𝑛 𝑆(𝑛 + 𝑚′ , 𝑚 + 𝑚′ ) for capacitated
problems
If 𝑚′ = 𝑂(𝑚) we can solve the shortest path
problem in 𝑂(𝑚𝑙𝑜𝑔 𝑛 )
Can we improve that?
Improved Shortest Path

Idea: If node 𝑘 is adjacent to only 2 nodes, 𝑖 and 𝑗 ,in
the residual network we can eliminate node k from
the network:
𝑖
𝑖
𝑖
𝜋
𝑐𝑖𝑘
𝜋
𝜋
𝑐𝑖𝑘
+ 𝑐𝑘𝑗
𝑘
𝜋
𝜋
𝑐𝑗𝑘
+ 𝑐𝑘𝑖
𝑘
𝜋
𝑐𝑘𝑗
𝑗
𝑖
𝜋
𝑐𝑘𝑖
𝜋
𝑐𝑗𝑘
𝑗
𝑗
𝜋
𝜋
𝑑 𝑘 = 𝑚𝑖𝑛 𝑑 𝑖 + 𝑐𝑖𝑘
, 𝑑 𝑗 + 𝑐𝑗𝑘
𝑗
Contracted Network

Let 𝐺(𝑥) denote the residual network corresponding
to a pseudo flow 𝑥. The Nodes in 𝐺(𝑥) can be:


Original Nodes - 𝑁 ∪ 𝑁2
Contracted Nodes – contains at least one original node

We form a new network 𝐺 ′ = (𝑁 ′ , 𝐴′ ) by eliminating
original nodes in 𝑁2

𝐺 ′ is used to find shortest paths
Contracted Network

Each node 𝑘 ∈ 𝑁2 is replaced with the two arc incident
to it say (𝑖, 𝑘) and (𝑗, 𝑘) as follows:




if 𝑥𝑖𝑘 > 0 add arc (𝑗, 𝑖) with length:
𝜋
𝜋
𝜋
𝜋
𝑙𝑗𝑖 = 𝑐𝑗𝑘
− 𝑐𝑖𝑘
= 𝑐𝑗𝑘
≥ 0 (𝑐𝑖𝑘
= 0)
if 𝑥𝑗𝑘 > 0 add arc (𝑖, 𝑗) with length:
𝜋
𝜋
𝜋
𝜋
𝑙𝑖𝑗 = 𝑐𝑖𝑘
− 𝑐𝑗𝑘
= 𝑐𝑖𝑘
≥ 0 (𝑐𝑗𝑘
= 0)
𝜋
For each arc (𝑖, 𝑗) that is not replaced 𝑙𝑖𝑗 = 𝑐𝑖𝑗
If 𝑑 is the shortest paths lengths in 𝐺 ′ we can determine
the shortest paths in 𝐺.


For each node 𝑘 ∈ 𝑁2 with two arcs incident (𝑖, 𝑘) and 𝑗, 𝑘 :
𝜋
𝜋
𝑑 𝑘 = 𝑚𝑖𝑛 𝑑 𝑖 + 𝑐𝑖𝑘
, 𝑑 𝑗 + 𝑐𝑗𝑘
We can calculate the shortest path in 𝐺 in an addition of 𝑂(𝑚)
units of time
Calculating Shortest Paths

𝐺 ′ (𝑋) has at most 𝑛 nodes, 𝑚 + 2𝑚′ = 𝑂(𝑚) arcs
and all arc length are none negative

We can calculate shortest path in 𝑂 𝑚 + 𝑛𝑙𝑜𝑔 𝑛
(Fredman & Tarjan)
Conclusion

We have seen an algorithm for solving the capacitated
minimum cost flow as a sequence of 𝑂(𝑚𝑙𝑜𝑔 𝑛 )
shortest path problems

Using the Improved shortest path algorithm we can
solve a shortest path problem in 𝑂(𝑚 + 𝑛𝑙𝑜𝑔 𝑛 )
time

Total running time of the algorithm is 𝑂 𝑚𝑙𝑜𝑔 𝑛 𝑚
THE END
QUESTIONS?