Maximum Flow - Algorithm and Complexity Analysis - Lecture Slides, Slides of Computer Science

These are the Lecture Slides of Algorithm and Complexity Analysis which includes Approximation Algorithms, Coping with Np-Hardness, Fully Polynomial-Time, Brute-Force Algorithms, Approximation Scheme, Knapsack Problem, Profit Subset of Items, Nonnegative Values etc. Key important points are:Maximum Flow, Minimum Cut, Max Flow Network, Augmenting Path Algorithm, Capacity-Scaling, Shortest Augmenting Path, Egalitarian Stable Matching, Network Reliability, Distributed Computing

Typology: Slides

2012/2013

Uploaded on 03/21/2013

dharmaveer
dharmaveer 🇮🇳

4.5

(4)

54 documents

1 / 14

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Maximum Flow
2
Contents
Contents.
Maximum flow problem.
Minimum cut problem.
Max-flow min-cut theorem.
Augmenting path algorithm.
Capacity-scaling.
Shortest augmenting path.
3
Network reliability.
Security of statistical data.
Distributed computing.
Egalitarian stable matching.
Distributed computing.
Many many more . . .
Maximum Flow and Minimum Cut
Max flow and min cut.
Two very rich algorithmic problems.
Cornerstone problem in combinatorial optimization.
Beautiful mathematical duality.
Nontrivial applications / reductions.
Network connectivity.
Bipartite matching.
Data mining.
Open-pit mining.
Airline scheduling.
Image processing.
Project selection.
Baseball elimination.
4
Max flow network: G = (V, E, s, t, u) .
(V, E) = directed graph, no parallel arcs.
Two distinguished nodes: s = source, t = sink.
u(e) = capacity of arc e.
Max Flow Network
Capacity
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
610
10
10
15
4
4
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download Maximum Flow - Algorithm and Complexity Analysis - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

Maximum Flow

Contents

Contents.

n^

Maximum flow problem.

n^

Minimum cut problem.

n^

Max-flow min-cut theorem.

n^

Augmenting path algorithm.

n^

Capacity-scaling.

n^

Shortest augmenting path.

3

n^

Network reliability. n^

Security of statistical data. n^

Distributed computing. n^

Egalitarian stable matching. n^

Distributed computing. n^

Many many more...

Maximum Flow and Minimum Cut

Max flow and min cut.

n^

Two very rich algorithmic problems. n^

Cornerstone problem in combinatorial optimization. n^

Beautiful mathematical duality.

Nontrivial applications / reductions.

n^

Network connectivity. n^

Bipartite matching. n^

Data mining. n^

Open-pit mining. n^

Airline scheduling. n^

Image processing. n^

Project selection. n^

Baseball elimination.

Max flow network: G = (V, E, s, t, u).

n^

(V, E) = directed graph, no parallel arcs. n^

Two distinguished nodes: s = source, t = sink. n^

u(e) = capacity of arc e.

Max Flow Network

Capacity

s

2 3 4

5 6 7

t

(^515)

30

15

10

(^91586)

10 10 10

15

4 4

Docsity.com

5

An s-t flow is a function f: E

that satisfies:

n^

For each e

E:

f(e)

u(e)

(capacity)

n^

For each v

V – {s, t}:

(conservation)

Flows

v

e

v

e

e f

e f

of out

to in

s

2 3 4

5 6 7

t

(^515)

30

15

10

(^91586)

10 10 10

15

4 4

4

0

0

0

0 0

0

0

4

4

0

4

(^00)

0

Capacity

Flow

E w v w v e

w

v

f

e

f

) , (:

of out

E v w w v e

v

w

f

e

f^

) , (:

to in

An s-t flow is a function f: E

that satisfies:

n^

For each e

E:

f(e)

u(e)

(capacity)

n^

For each v

V – {s, t}:

(conservation)

MAX FLOW: find s-t flow that maximizes net flow out of the source.

Flows

s

2 3 4

5 6 7

t

(^515)

30

15

10

(^91586)

10 10 10

15

4 4

4

0

0

0

0 0

0

0

4

4

0

4

0

Value = 4

s

e

e f

f

of

out

0

0

Capacity

Flow

v

e

v

e

e f

e f

of out

to in

7

An s-t flow is a function f: E

that satisfies:

n^

For each e

E:

f(e)

u(e)

(capacity)

n^

For each v

V – {s, t}:

(conservation)

MAX FLOW: find s-t flow that maximizes net flow out of the source.

Flows

s

2 3 4

5 6 7

t

(^515)

30

15

10

(^91586)

10 10 10

15

4 4

10

6

6

11

(^111)

10

3

8

8

0

4

0

Value = 24

0

0

Capacity

Flow

v

e

v

e

e f

e f

of out

to in

An s-t flow is a function f: E

that satisfies:

n^

For each e

E:

f(e)

u(e)

(capacity)

n^

For each v

V – {s, t}:

(conservation)

MAX FLOW: find s-t flow that maximizes net flow out of the source.

Flows

s

2 3 4

5 6 7

t

(^515)

30

15

10

(^91586)

10 10 10

15

4 4

10

9

9

14

(^414)

10

4

8

9

1

0

0

Value = 28

0

0

Capacity

Flow

v

e

v

e

e f

e f

of out

to in

Docsity.com

13

L1. Let f be a flow, and let (S, T) be a cut. Then, the net flow sentacross the cut is equal to the amount reaching t.

Flows and Cuts

s

2 3 4

5 6 7

t

(^515)

30

15

10

(^91586)

10 10 10

15

4 4

f e f e f e f

s e S e S e

of out

to in

of

out

Value = 24

10

6

6

10

(^010)

10

4

8

8

0

4

(^00)

0

10

6

6

10

(^010)

10

4

8

8

0

4

(^00)

0

L1. Let f be a flow, and let (S, T) be a cut. Then, the net flow sentacross the cut is equal to the amount reaching t.

Flows and Cuts

s

2 3 4

5 6 7

t

(^515)

30

15

10

(^91586)

10 10 10

15

4 4

f e f e f e f

s e S e S e

of out

to in

of

out

Value = 24

15

10

6

6

10

(^010)

10

4

8

8

0

4

(^00)

L1. Let f be a flow, and let (S, T) be a cut. Then, the net flow sentacross the cut is equal to the amount reaching t.

Flows and Cuts

s

2 3 4

5 6 7

t

(^515)

30

15

10

(^91586)

10 10 10

15

4 4

f e f e f e f

s e S e S e

of out

to in

of

out

Value = 24

0

Let f be a flow, and let (S, T) be a cut. Then,Proof by induction on |S|.

n^

Base case: S = { s }. n^

Inductive hypothesis: assume true for |S| < k.

consider cut (S, T) with |S| = k -

S = S’

{ v } for some v

s, t, |S’ | = k-

cap(S’, T’) = | f |.

adding v to S’ increase cut capacity by

Flows and Cuts

to in

of

out

S

e

S

e

f

e f

e f

to in

of

out

v

e

v

e

e f

e f

s

v

t

After

s

v

t

S’

Before

S

Docsity.com

17

L2. Let f be a flow, and let (S, T) be a cut. Then, | f |

cap(S, T).

Proof. Corollary. Let f be a flow, and let (S, T) be a cut. If |f| = cap(S, T), thenf is a max flow and (S, T) is a min cut.

Flows and Cuts

T)

cap(S,

of out

of out

to in

of out

S

e

S

e

S

e

S

e

e u

e f

e f

e f

f

s

t

S
T

(^4876)

Max Flow and Min Cut

Corollary. Let f be a flow, and let (S, T) be a cut. If |f| = cap(S, T), thenf is a max flow and (S, T) is a min cut.

s

2 3 4

5 6 7

t

(^515)

30

15

10

(^91586)

10 10 10

15

4 4

10

9

9

15

(^415)

10

4

8

9

1

0

0

Flow value = 28

0

0

Cut capacity = 28

19

Max-Flow Min-Cut Theorem

MAX-FLOW MIN-CUT THEOREM (Ford-Fulkerson, 1956): In anynetwork, the value of the max flow is equal to the value of the min cut.

n^

"Good characterization." n^

Proof IOU.

s

2 3 4

5 6 7

t

(^515)

30

15

10

(^91586)

10 10 10

15

4 4

10

9

9

15

(^415)

10

4

8

9

1

0

0

Flow value = 28

0

0

Cut capacity = 28

Towards an Algorithm

Find an s-t path where each arc has u(e) > f(e) and "augment" flowalong the path.

s

4 2

5 3

t

4

0

0

0

0

0

(^0404)

4

Flow value = 0

10

13

10

Docsity.com

25

Augmenting Path

Augmenting path = path in residual graph.

s

4 2

5 3

t

10

13

(^410)

0

0

10

10

10

(^0404)

4

s

4 2

5 3

t

10

10

(^410)

(^44)

4

3

G G

f

4

4

6

4 4

X X

X

X

X

Augmenting Path

Augmenting path = path in residual graph.

n^

Max flow

no augmenting paths ???

s

4 2

5 3

t

10

13

(^410)

4

4

10

6

10

(^4444)

4

s

4 2

5 3

t

10

6

(^410)

(^44)

4

7

Flow value = 14

G G

f

27

Max-Flow Min-Cut Theorem

Augmenting path theorem (Ford-Fulkerson, 1956): A flow f is a maxflow if and only if there are no augmenting paths.MAX-FLOW MIN-CUT THEOREM (Ford-Fulkerson, 1956): the value ofthe max flow is equal to the value of the min cut.We prove both simultaneously by showing the TFAE:

(i)

f is a max flow.

(ii)

There is no augmenting path relative to f.

(iii)

There exists a cut (S, T) such that |f| = cap(S, T).

Proof of Max-Flow Min-Cut Theorem

We prove both simultaneously by showing the TFAE:

(i)

f is a max flow.

(ii)

There is no augmenting path relative to f.

(iii)

There exists a cut (S, T) such that |f| = cap(S, T).

(i)

(ii)

n^

We show contrapositive. n^

Let f be a flow. If there exists an augmenting path, then we canimprove f by sending flow along path.

(iii)

(i)

n^

Next slide.

(iii)

(i)

n^

This was the Corollary to Lemma 2.

Docsity.com

29

Proof of Max-Flow Min-Cut Theorem

We prove both simultaneously by showing the TFAE:

(i)

f is a max flow.

(ii)

There is no augmenting path relative to f.

(iii)

There exists a cut (S, T) such that |f| = cap(S, T).

(ii)

(iii)

n^

Let f be a flow with no augmenting paths. n^

Let S be set of vertices reachable from s in residual graph.

clearly s

S, and t

S by definition of f

T)
(S,

of

out

to in

of

out cap

e u

e f

e f

f

S

e

S

e

S

e

= =

s

t

Original Network S

T

Augmenting Path Algorithm

b

bottleneck(P)

FOREACH

e

P

IF (e

E) // forward arc

f(e)

f(e) + b

ELSE

// backwards arc

f(e

R

f(e) - b

RETURN f

Augment (f, P)

FOREACH

e

E

f(e)

G

f

residual graph

WHILE (there exists augmenting path P)

f

augment(f, P)

update G

f

RETURN f

FordFulkerson (V, E, s, t)

31

Running Time

Assumption: all capacities are integers between 0 and U.Invariant: every flow value f(e) and every residual capacities u

f^ (e)

remains an integer throughout the algorithm.Theorem: the algorithm terminates in at most | f * |

nU iterations.

Corollary: if U = 1, then algorithm runs in O(mn) time.Integrality theorem: if all arc capacities are integers, then there existsa max flow f for which every flow value f(e) is an integer.Note: algorithm may not terminate on some pathological instances(with irrational capacities). Moreover, flow value may not evenconverge to correct answer.

100

(^00)

s

4 2

t

1

100 100

0

0 0

Choosing Good Augmenting Paths

Use care when selecting augmenting paths.

100

Docsity.com

37

Choosing Good Augmenting Paths

Use care when selecting augmenting paths.

n^

Some choices lead to exponential algorithms. n^

Clever choices lead to polynomial algorithms.

Goal: choose augmenting paths so that:

n^

Can find augmenting paths efficiently. n^

Few iterations.

Edmonds-Karp (1972): choose augmenting path with

n^

Max bottleneck capacity.

(fat path)

n^

Sufficiently large capacity.

(capacity-scaling)

n^

Fewest number of arcs.

(shortest path)

Capacity Scaling

Intuition: choosing path with highest bottleneck capacity increasesflow by max possible amount.

n^

Don’t worry about finding exact highest bottleneck path. n^

Maintain scaling parameter

n^

Let G

f^

) be the subgraph of the residual graph consisting of only

arcs with capacity at least

110

s

4 2

t

1

102 170

122

G

f

110

s

4 2

t

102 170

122

G

f^

39

Capacity Scaling

Intuition: choosing path with highest bottleneck capacity increasesflow by max possible amount.

n^

Don’t worry about finding exact highest bottleneck path. n^

Maintain scaling parameter

n^

Let G

f^

) be the subgraph of the residual graph consisting of only

arcs with capacity at least

FOREACH

e

E, f(e)

smallest power of 2 greater than or equal to U

WHILE (
G

f

-residual graph

WHILE (there exists augmenting path P in G

f

f

augment(f, P)

update G

f

RETURN f

ScalingMaxFlow(V, E, s, t)

Capacity Scaling: Analysis

L1. If all arc capacities are integers, then throughout the algorithm, allflow and residual capacity values remain integers.

n^

Thus,

G

(f

G

f^ , so upon termination f is a max flow.

L2. The outer while loop repeats 1 +

log

2

U

times.

n^

Initially U

< 2U,and

decreases by a factor of 2 each iteration.

L3. Let f be the flow at the end of a

-scaling phase. Then value of the

maximum flow is at most | f | + m

L4. There are at most 2m augmentations per scaling phase.

n^

Let f be the flow at the end of the previous scaling phase. n^

L

|f*|

| f | + m (

n^

Each augmentation in a

-phase increases | f | by at least

Theorem. The algorithm runs in O(m

2 log (2U) ) time.

Docsity.com

41

Capacity Scaling: Analysis

L3. Let f be the flow at the end of a

-scaling phase. Then value of the

maximum flow is at most |f| + m

n^

We show that at the end of a

-phase, there exists a cut (S, T) such

that cap(S, T)

| f | + m

n^

Choose S to be the set of nodes reachable from s in G

(f

clearly s

S, and t

S by definition of S

m

T)

cap(S,

e u

e u

e f

e f

f

S e S e S e

S

e

S

e

S

e

S

e

=

to in

of

out

of out

to in

of out

to in

of out

s

t

Original Network S

T

Choosing Good Augmenting Paths

Use care when selecting augmenting paths.

n^

Some choices lead to exponential algorithms. n^

Clever choices lead to polynomial algorithms.

Goal: choose augmenting paths so that:

n^

Can find augmenting paths efficiently. n^

Few iterations.

Edmonds-Karp (1972): choose augmenting path with

n^

Max bottleneck capacity.

(fat path)

n^

Sufficiently large capacity.

(capacity-scaling)

n^

Fewest number of arcs.

(shortest path)

43

Shortest Augmenting Path

Intuition: choosing path via breadth first search.

n^

Easy to implement.

may implement by coincidence!

n^

Finds augmenting path with fewest number of arcs.

FOREACH

e

E

f(e)

G

f

residual graph

WHILE (there exists augmenting path)

find such a path P by BFSf

augment(f, P)

update G

f

RETURN f

ShortestAugmentingPath(V, E, s, t)

Shortest Augmenting Path: Overview of AnalysisL1. Throughout the algorithm, the length of the shortest path neverdecreases.

n^

Proof ahead.

L2.

After at most m shortest path augmentations, the length of the

shortest augmenting path strictly increases.

n^

Proof ahead.

Theorem. The shortest augmenting path algorithm runs in O(m

2 n)

time.

n^

O(m+n) time to find shortest augmenting path via BFS. n^

O(m) augmentations for paths of exactly k arcs. n^

If there is an augmenting path, there is a simple one. ⇒

k < n

O(mn) augmentations.

Docsity.com

49

Shortest Augmenting Path: Review of Analysis

L1. Throughout the algorithm, the length of the shortest path neverdecreases.L2.

After at most m shortest path augmentations, the length of the

shortest augmenting path strictly increases.Theorem. The shortest augmenting path algorithm runs in O(m

2 n)

time.

n^

O(m+n) time to find shortest augmenting path via BFS. n^

O(m) augmentations for paths of exactly k arcs. n^

O(mn) augmentations.

Note:

(mn) augmentations necessary on some networks.

n^

Try to decrease time per augmentation instead. n^

Dynamic trees

O(mn log n)

Sleator-Tarjan, 1983

n^

Simple idea

O(mn

2

Shortest Augmenting Path: Improved Version

Two types of augmentations.

n^

Normal augmentation: length of shortest path doesn’t change. n^

Special augmentation: length of shortest path strictly increases.

L3. Group of normal augmentations takes O(mn) time.

n^

Explicitly maintain level graph - it changes by at most 2n arcs aftereach normal augmentation. n^

Start at s, advance along an arc in L

G

until reach t or get stuck.

if reach t, augment and delete at least one arc - if get stuck, delete node

s

2 3

5 6

t

l

l

l

l

L

G

51

Shortest Augmenting Path: Improved Version

s

2 3

5 6

t

L

G

s

2 3

5 6

t

L

G

s

2

5 6

t

L

G

augment delete 3 augment

Shortest Augmenting Path: Improved Version

s

2

5 6

t

L

G

s

2

5 6

t

L

G

STOP: length of shortest path must havestrictly increased

augment Docsity.com

53

Shortest Augmenting Path: Improved Version

ARRAY pred[v

V]
L

G

level graph of G

f

v

s, pred[v]

nil

REPEAT

WHILE (there exists (v,w)

L

G

pred[w]

v, v

w

IF (v = t)

P

path defined by pred[]

f

augment(f, P)

update L

G

v

s, pred[v]

nil

delete v from L

G

UNTIL (v =

s)

RETURN f

AdvanceRetreat(V, E, f, s, t)

advance retreat

augment

Shortest Augmenting Path: Improved Version

Two types of augmentations.

n^

Normal augmentation: length of shortest path doesn’t change. n^

Special augmentation: length of shortest path strictly increases.

L3. Group of normal augmentations takes O(mn) time.

n^

Explicitly maintain level graph - it changes by at most 2n arcs aftereach normal augmentation. n^

Start at s, advance along an arc in L

G

until reach t or get stuck.

if reach t, augment and delete at least one arc - if get stuck, delete node - at most n advance steps before one of above events

Theorem. Algorithm runs in O(mn

2 ) time.

n^

O(mn) time between special augmentations. n^

At most n special augmentations.

55

Choosing Good Augmenting Paths: Summary

First 4 rules assume arc capacities are between 0 and U.

Method

Augmentations

Augmenting path

nU

Max capacity

m

log U

Capacity scaling

m

log U

Shortest path

mn

Running time

mnU

m log U (m + n log n)

m

2

log U m

2 n

Improved shortest path

mn

mn

2

Improved capacity scaling

m

log U

mn log U

History

Dantzig Discoverer

MethodSimplex

Big-Ohmn

2 U

Year 1951

Ford, Fulkerson

Augmenting path

mnU

Edmonds-Karp

Shortest path

m

2 n

Dinitz

Shortest path

mn

2

Edmonds-Karp, Dinitz

Capacity scaling

m

2 log U

Dinitz-Gabow

Capacity scaling

mn log U

Karzanov

Preflow-push

n

3

Sleator-Tarjan

Dynamic trees

mn log n

Goldberg-Tarjan

FIFO preflow-push

mn log (n

2

/ m)

Goldberg-Rao

Length function

m

3/

log (n

2 / m) log U

mn

2/

log (n

2 / m) log U

Docsity.com