chapter 26. maximum flow › ~aebnenas › teaching › fall2008 › ... · introduction the...

52
Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Chapter 26. Maximum Flow Hao Wang Department of Computer Science Michigan Technological University November 4, 2008 Hao Wang Chapter 26. Maximum Flow

Upload: others

Post on 25-Jun-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Chapter 26. Maximum Flow

Hao Wang

Department of Computer ScienceMichigan Technological University

November 4, 2008

Hao Wang Chapter 26. Maximum Flow

Page 2: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Outline

1 Introduction

2 The Ford-Fulkerson Method

3 The Edmonds-Karp Algorithm

4 Maximum Bipartite Matching

Hao Wang Chapter 26. Maximum Flow

Page 3: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Outline

1 Introduction

2 The Ford-Fulkerson Method

3 The Edmonds-Karp Algorithm

4 Maximum Bipartite Matching

Hao Wang Chapter 26. Maximum Flow

Page 4: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Flow Networks

Definition: A flow network is a directed graph G = (V ,E ) withtwo distinguished vertices: a source s and a sink t. Each edge(u, v) ∈ E has a nonnegative capacity c(u, v). If (u, v) /∈ E , thenc(u, v) = 0.

Hao Wang Chapter 26. Maximum Flow

Page 5: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Flow Networks (cont.)

A flow in G is a real-valued function f : V × V → R thatsatisfies:

Capacity constraint: For all u, v ∈ V , f (u, v) ≤ c(u, v).Skew symmetry: For all u, v ∈ V , f (u, v) = −f (v , u).Flow conservation: For all u ∈ V − {u, v},∑

v∈V

f (u, v) = 0.

Hao Wang Chapter 26. Maximum Flow

Page 6: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

The Max Flow Problem

The value of a flow is the net flow out of the source:∑v∈V

f (s, v)−∑v∈V

f (v , s).

Maximum-flow problem: Given a flow network G , find a flowof maximum value on G .

The value of max flow of this example is 4.

Hao Wang Chapter 26. Maximum Flow

Page 7: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Different Networks

Multiple sources and sinks

Flow capacity on vertices

Hao Wang Chapter 26. Maximum Flow

Page 8: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Outline

1 Introduction

2 The Ford-Fulkerson Method

3 The Edmonds-Karp Algorithm

4 Maximum Bipartite Matching

Hao Wang Chapter 26. Maximum Flow

Page 9: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Cuts of Flow Networks

Definition: A cut (S ,T ) of a flow network G = (V ,E ) is apartition of V such that s ∈ S and t ∈ T .

If f is a flow, then the net flow across the cut (S ,T ) is definedto be f (S ,T ). The capacity of the cut (S ,T ) is c(S ,T ).

f (S ,T ) = (2 + 2) + (−2 + 1− 1 + 0 + 2) = 4

c(S ,T ) = (3 + 2) + (1 + 2 + 3) = 11

If f is a flow and (S ,T ) is a cut, then f ≤ c(S ,T ).

Hao Wang Chapter 26. Maximum Flow

Page 10: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Residual Network

Definition: Let f be a flow on G = (V ,E ). The residualnetwork Gf = (V ,Ef ) is the graph with strictly positiveresidual capacities.

cf (u, v) = c(u, v)− f (u, v).

f (u, v) = −f (v , u) = −3

Hao Wang Chapter 26. Maximum Flow

Page 11: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Augmenting Paths

Definition: Any path from s to t in Gf is an augmentingpath in G with respect to f . The flow value can be increasedalong an augmenting path p by

cf (p) = min{cf (u, v) : (u, v) is on p}.

Hao Wang Chapter 26. Maximum Flow

Page 12: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Example

Hao Wang Chapter 26. Maximum Flow

Page 13: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Max-flow Min-cut Theorem

Theorem: If f is a flow in a flow network G = (V ,E ) withsource s and sink t, then the following conditions areequivalent:

1 f is a maximum flow in G .2 The residual network Gf contains no augmenting paths.3 |f | = c(S ,T ) for some cut (S ,T ) of G .

Hao Wang Chapter 26. Maximum Flow

Page 14: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

The Ford-Fulkerson Method

Ford-Fulkerson-Method(G , s, t)

1 initialize flow f to 02 while there exists an augmenting path p3 do augment flow f along p4 return f

Hao Wang Chapter 26. Maximum Flow

Page 15: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

The Ford-Fulkerson Algorithm

More precisely,

Ford-Fulkerson(G , s, t)

1 for each edge (u, v) ∈ E2 do f [u, v ]← 03 f [v , u]← 04 while there exists an augmenting path p from s to t in Gf

5 do cf (p)← min{cf (u, v) : (u, v) is in p}6 for each edge (u, v) in p7 do f [u, v ]← f [u, v ] + cf (p)8 f [v , u]← −f [u, v ]9 return f

Hao Wang Chapter 26. Maximum Flow

Page 16: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

example

Hao Wang Chapter 26. Maximum Flow

Page 17: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

example

Hao Wang Chapter 26. Maximum Flow

Page 18: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

example

Hao Wang Chapter 26. Maximum Flow

Page 19: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

example

Hao Wang Chapter 26. Maximum Flow

Page 20: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

example

Hao Wang Chapter 26. Maximum Flow

Page 21: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

example

Hao Wang Chapter 26. Maximum Flow

Page 22: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

example

Hao Wang Chapter 26. Maximum Flow

Page 23: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

example

Hao Wang Chapter 26. Maximum Flow

Page 24: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

example

Hao Wang Chapter 26. Maximum Flow

Page 25: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Analysis of Ford-Fulkerson

The running time of Ford-Fulkerson depends on how todetermine the augmenting path p.

Hao Wang Chapter 26. Maximum Flow

Page 26: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Analysis of Ford-Fulkerson

The running time of Ford-Fulkerson depends on how todetermine the augmenting path p.

Hao Wang Chapter 26. Maximum Flow

Page 27: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Analysis of Ford-Fulkerson

The running time of Ford-Fulkerson depends on how todetermine the augmenting path p.

Hao Wang Chapter 26. Maximum Flow

Page 28: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Analysis of Ford-Fulkerson

The running time of Ford-Fulkerson depends on how todetermine the augmenting path p.

Hao Wang Chapter 26. Maximum Flow

Page 29: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Analysis of Ford-Fulkerson

The running time of Ford-Fulkerson depends on how todetermine the augmenting path p.

Hao Wang Chapter 26. Maximum Flow

Page 30: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Analysis of Ford-Fulkerson

The running time of Ford-Fulkerson depends on how todetermine the augmenting path p.

Hao Wang Chapter 26. Maximum Flow

Page 31: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Analysis of Ford-Fulkerson

The running time of Ford-Fulkerson depends on how todetermine the augmenting path p.

Hao Wang Chapter 26. Maximum Flow

Page 32: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Analysis of Ford-Fulkerson

The running time of Ford-Fulkerson depends on how todetermine the augmenting path p.

Hao Wang Chapter 26. Maximum Flow

Page 33: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Analysis of Ford-Fulkerson

The running time of Ford-Fulkerson depends on how todetermine the augmenting path p.

2 billion iterations on a graph with 4 vertices.

Even fails to terminate when edge capacities are irrationalnumbers.

When the capacities are rational numbers, the running time isO(E |f ∗|), where f ∗ is the maximum flow.

Hao Wang Chapter 26. Maximum Flow

Page 34: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Outline

1 Introduction

2 The Ford-Fulkerson Method

3 The Edmonds-Karp Algorithm

4 Maximum Bipartite Matching

Hao Wang Chapter 26. Maximum Flow

Page 35: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

The Edmonds-Karp Algorithm

How to find augmenting paths? BFS or DFS?Ford-Fulkerson(G , s, t)

1 for each edge (u, v) ∈ E2 do f [u, v ]← 03 f [v, u]← 04 while there exists an augmenting path p from s to t in Gf5 do cf (p)← min{cf (u, v) : (u, v) is in p}6 for each edge (u, v) in p7 do f [u, v ]← f [u, v ] + cf (p)8 f [v, u]← −f [u, v ]9 return f

Edmonds-Karp Algorithms: Find the augment path p witha breadth-first search, thus such augmenting path is a shortestpath from s to t in the residual network, where each edge hasunit distance.

Let δf (u, v) be the shortest-path distance from u to v in Gf .δ(u) = δf (s, u) increase monotonically with each flowaugmentation, where s is the source.

Hao Wang Chapter 26. Maximum Flow

Page 36: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Critical edge

Let p be an augmenting path, and suppose that the residualcapacity of edge (u, v) ∈ p is cf (u, v) = cf (p). Then, we say(u, v) is critical, and it disappears from the residual graphafter flow augmentation.

Hao Wang Chapter 26. Maximum Flow

Page 37: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Critical edge

Let p be an augmenting path, and suppose that the residualcapacity of edge (u, v) ∈ p is cf (u, v) = cf (p). Then, we say(u, v) is critical, and it disappears from the residual graphafter flow augmentation.

Hao Wang Chapter 26. Maximum Flow

Page 38: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

δ(u)

The first time an edge (u, v) is critical, we haveδ(v) = δ(u) + 1, since p is a breadth-first path. We must waituntil (v , u) is on an augmenting path before (u, v) can becritical again. Let δ′ be the distance function when (v , u) ison an augmenting path. Then, we have

δ′(u) = δ′(v) + 1 breath-first path

≥ δ(v) + 1 monotonicity

= δ(u) + 2 breadth-first path

Hao Wang Chapter 26. Maximum Flow

Page 39: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

δ(u)

The first time an edge (u, v) is critical, we haveδ(v) = δ(u) + 1, since p is a breadth-first path. We must waituntil (v , u) is on an augmenting path before (u, v) can becritical again. Let δ′ be the distance function when (v , u) ison an augmenting path. Then, we have

δ′(u) = δ′(v) + 1 breath-first path

≥ δ(v) + 1 monotonicity

= δ(u) + 2 breadth-first path

Hao Wang Chapter 26. Maximum Flow

Page 40: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

δ(u)

The first time an edge (u, v) is critical, we haveδ(v) = δ(u) + 1, since p is a breadth-first path. We must waituntil (v , u) is on an augmenting path before (u, v) can becritical again. Let δ′ be the distance function when (v , u) ison an augmenting path. Then, we have

δ′(u) = δ′(v) + 1 breath-first path

≥ δ(v) + 1 monotonicity

= δ(u) + 2 breadth-first path

Hao Wang Chapter 26. Maximum Flow

Page 41: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

δ(u)

The first time an edge (u, v) is critical, we haveδ(v) = δ(u) + 1, since p is a breadth-first path. We must waituntil (v , u) is on an augmenting path before (u, v) can becritical again. Let δ′ be the distance function when (v , u) ison an augmenting path. Then, we have

δ′(u) = δ′(v) + 1 breath-first path

≥ δ(v) + 1 monotonicity

= δ(u) + 2 breadth-first path

Hao Wang Chapter 26. Maximum Flow

Page 42: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

δ(u)

The first time an edge (u, v) is critical, we haveδ(v) = δ(u) + 1, since p is a breadth-first path. We must waituntil (v , u) is on an augmenting path before (u, v) can becritical again. Let δ′ be the distance function when (v , u) ison an augmenting path. Then, we have

δ′(u) = δ′(v) + 1 breath-first path

≥ δ(v) + 1 monotonicity

= δ(u) + 2 breadth-first path

Hao Wang Chapter 26. Maximum Flow

Page 43: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

δ(u)

The first time an edge (u, v) is critical, we haveδ(v) = δ(u) + 1, since p is a breadth-first path. We must waituntil (v , u) is on an augmenting path before (u, v) can becritical again. Let δ′ be the distance function when (v , u) ison an augmenting path. Then, we have

δ′(u) = δ′(v) + 1 breath-first path

≥ δ(v) + 1 monotonicity

= δ(u) + 2 breadth-first path

Hao Wang Chapter 26. Maximum Flow

Page 44: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Analysis of Edmonds-Karp

From the time (u, v) becomes critical to the time when it nextbecomes critical, the distance of u from the source increase bytwo at least.

δ(u) is initially at least 0. Until u becomes unreachable fromthe source, its distance is at most |V | − 2, assuming u is notthe sink t. Thus, (u, v) can become critical at most12(|V | − 2) times.

Since there are O(E ) pairs of vertices that can have an edgebetween them in a residual graph, the total number of criticaledges during the entire execution of the Edmonds-Karpalgorithm is O(V E ).

It takes O(E ) to determine an augmenting path usingbreadth-first search, therefore, the total running time of theEdmonds-Karp algorithm is O(V E 2).

Hao Wang Chapter 26. Maximum Flow

Page 45: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Example:

How many iterations are needed when Edmonds-Karpalgorithm is used?

Hao Wang Chapter 26. Maximum Flow

Page 46: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Outline

1 Introduction

2 The Ford-Fulkerson Method

3 The Edmonds-Karp Algorithm

4 Maximum Bipartite Matching

Hao Wang Chapter 26. Maximum Flow

Page 47: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Bipartite Matching

Given an undirected graph G = (V ,E ), a matching is a subsetof edges M ⊆ E such that for all vertices v ∈ V , at most oneedge of M is incident on v .

A vertex v is matched by matching M if some edge in M isincident on v ; otherwise, v is unmatched.

Hao Wang Chapter 26. Maximum Flow

Page 48: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

The Maximum-Bipartite-Matching Problem

A maximum matching is a matching of maximum cardinality.

Hao Wang Chapter 26. Maximum Flow

Page 49: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

The Corresponding Flow Network

Define the corresponding flow network G ′ = (V ′,E ′).Add the source s and sink t to V , i.e., V ′ = V + {s, t}.The directed edges of G ′ are the edges of G , directed from Lto R, along with new directed edges from s to each vertex in Land from each vertex in R to t.Each edge in G ′ has a unit capacity.

Hao Wang Chapter 26. Maximum Flow

Page 50: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Maximum-Flow and Maximum-Matching

A flow f on a flow network G ′ = (V ′,E ′) is integer-valued iff (u, v) is an integer for all (u, v) ∈ E ′.Lemma 26.10 If M is a matching in G , then there is aninteger-valued flow f in G ′ with value |f | = |M|. Conversely,if f is an integer-valued flow in G ′, then there is a matchingM in G with cardinality |M| = |f |.Therefore, a maximum matching in a bipartite graph Gcorresponds to a maximum flow in its corresponding flownetwork G ′.

Hao Wang Chapter 26. Maximum Flow

Page 51: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Integrality Theorem

Theorem 26.11If the capacity function c takes on only integral values, thenthe maximum flow f produced by the Ford-Fulkerson methodhas the property that |f | is integer-valued. Moreover, for allvertices u and v , the value of f (u, v) is an integer.

Since we run the Ford-Fulkerson method in order to get amaximum matching M, the running time is expected to beO(E ′ |f ∗|), where f ∗ is the maximum flow, i.e., the cardinality|M|. Because any matching in a bipartite graph hascardinality at most min(|L|, |R|) = O(V ), we can thereforefind a maximum matching in a bipartite graph in time

O(E ′ |f ∗|) = O(E ′ V ) = O(E V ).

Hao Wang Chapter 26. Maximum Flow

Page 52: Chapter 26. Maximum Flow › ~aebnenas › teaching › fall2008 › ... · Introduction The Ford-Fulkerson Method The Edmonds-Karp Algorithm Maximum Bipartite Matching Outline 1

IntroductionThe Ford-Fulkerson Method

The Edmonds-Karp AlgorithmMaximum Bipartite Matching

Questions?

Thank you!

Any questions?

Hao Wang Chapter 26. Maximum Flow