SLIDE 1 CSE 632: Analysis of Algorithms II: Combinatorial Optimization and Linear Programming (Fall 2020)
Network Flow
Lecturer: Shi Li
Department of Computer Science and Engineering University at Buffalo
SLIDE 2 2/77
Outline
1
Network Flow
2
Ford-Fulkerson Method Correctness of Ford-Fulkerson’s Method Running Time of Ford-Fulkerson-Type Algorithm
3
Applications of Network-Flow Single Commodity Flow with Multiple Sources and Sinks s-t Edge-Disjoint Paths Problem Bipartite Matching Problem
SLIDE 3
3/77
Flow Network
Abstraction of fluid flowing through edges Digraph G = (V, E) with source s ∈ V and sink t ∈ V
No edges enter s No edges leave t
Edge capacity c(e) ∈ R>0 for every e ∈ E
s t a b d c 12 14 9 4 7 16 13 20 4
SLIDE 4 4/77
- Def. An s-t flow is a function f : E → R such that
for every e ∈ E: 0 ≤ f(e) ≤ c(e) (capacity conditions) for every v ∈ V \ {s, t}:
f(e) =
f(e). (conservation conditions) The value of a flow f is val(f) =
f(e). Maximum Flow Problem Input: directed network G = (V, E), capacity function c : E → R>0, source s ∈ V and sink t ∈ V Output: an s-t flow f in G with the maximum val(f)
SLIDE 5
5/77
Maximum Flow Problem: Example s t a b d c 12/12 11/14 0/9 0/4 7/7 12/16 11/13 19/20 4/4
SLIDE 6 6/77
Outline
1
Network Flow
2
Ford-Fulkerson Method Correctness of Ford-Fulkerson’s Method Running Time of Ford-Fulkerson-Type Algorithm
3
Applications of Network-Flow Single Commodity Flow with Multiple Sources and Sinks s-t Edge-Disjoint Paths Problem Bipartite Matching Problem
SLIDE 7
7/77
Greedy Algorithm Start with empty flow: f(e) = 0 for every e ∈ E Define the residual capacity of e to be c(e) − f(e) Find an augmenting path: a path from s to t, where all edges have positive residual capacity Augment flow along the path as much as possible Repeat until we got stuck
SLIDE 8
8/77
Greedy Algorithm: Example s t a b d c 12/12 11/14 0/9 0/4 7/7 12/16 11/13 19/20 4/4
SLIDE 9
9/77
Greedy Algorithm Does Not Always Give a Optimum Solution
0/1 1/1 1/1 0/1 a b s t 1/1 0/1 0/1
SLIDE 10
10/77
Fix the Issue: Allowing “Undo” Flow Sent
a b s t 0/1 1/1 1/1 1/1 1/1
SLIDE 11 11/77
Assumption (u, v) and (v, u) can not both be in E
- Def. For a s-t flow f, the residual graph Gf of G = (V, E)
w.r.t f contains: the vertex set V , for every e = (u, v) ∈ E with f(e) < c(e), a forward edge e = (u, v), with residual capacity cf(e) = c(e) − f(e), for every e = (u, v) ∈ E with f(e) > 0, a backward edge e′ = (v, u), with residual capacity cf(e′) = f(e).
0/1 1/1 1/1 0/1 a b s t 1/1 0/1 0/1
Original graph G and f
1 a b s t 1 1 1 1
Residual Graph Gf
SLIDE 12
12/77
Residual Graph: One More Example
s t a b c d 4 12 8 5 1 4 4 4 s t a b c d 4/16 / 1 3 4/12 4 / 9 4/14 0/7 / 2 4/4 0/4 G Gf 4 13 7 20 4
SLIDE 13 13/77
Agumenting Path
Augmenting the flow along a path P from s to t in Gf Augment(P)
1: b ← min
e∈P cf(e)
2: for every (u, v) ∈ P do 3:
if (u, v) is a forward edge then
4:
f(u, v) ← f(u, v) + b
5:
else ⊲ (u, v) is a backward edge
6:
f(v, u) ← f(v, u) − b
7: return f
SLIDE 14
14/77
Example for Augmenting Along a Path
0/1 1 / 1 1/1 0/1 a b s t 1/1 0/1 0/1 1 a b s t 1 1 1 1
SLIDE 15 15/77
Ford-Fulkerson’s Method
Ford-Fulkerson(G, s, t, c)
1: let f(e) ← 0 for every e in G 2: while there is a path from s to t in Gf do 3:
let P be any simple path from s to t in Gf
4:
f ←augment(f, P)
5: return f
SLIDE 16
16/77
Ford-Fulkerson: Example
s t a b c d s t a b c d 1 1 / 1 3 11/14 7/7 1 5 / 2 G Gf 8/16 8/12 / 9 4/4 0/4 8 8 4 4 8 4 9 2 11 5 15 7 3 1 1
SLIDE 17 17/77
Outline
1
Network Flow
2
Ford-Fulkerson Method Correctness of Ford-Fulkerson’s Method Running Time of Ford-Fulkerson-Type Algorithm
3
Applications of Network-Flow Single Commodity Flow with Multiple Sources and Sinks s-t Edge-Disjoint Paths Problem Bipartite Matching Problem
SLIDE 18 18/77
Correctness of Ford-Fulkerson’s Method
1
The procedure augment(f, P) maintains the two conditions:
for every e ∈ E: 0 ≤ f(e) ≤ c(e) (capacity conditions) for every v ∈ V \ {s, t}:
f(e) =
f(e). (conservation conditions)
2
When Ford-Fulkerson’s Method terminates, val(f) is maximized
3
Ford-Fulkerson’s Method will terminate
SLIDE 19 19/77
Correctness of Ford-Fulkerson’s Method
1
The procedure augment(f, P) maintains the two conditions:
for every e ∈ E: 0 ≤ f(e) ≤ c(e) (capacity conditions) for every v ∈ V \ {s, t}:
f(e) =
f(e). (conservation conditions)
2
When Ford-Fulkerson’s Method terminates, val(f) is maximized
3
Ford-Fulkerson’s Method will terminate
SLIDE 20 20/77
for every e ∈ E: 0 ≤ f(e) ≤ c(e) (capacity conditions) for every v ∈ V \ {s, t}:
f(e) =
f(e). (conservation conditions)
s t +b +b −b −b +b
for an edge e correspondent to a forward edge : b ≤ c(e) − f(e) = ⇒ f(e) + b ≤ c(e) for an edge e correspondent to a backward edge : b ≤ f(e) = ⇒ f(e) − b ≥ 0
SLIDE 21 21/77
Correctness of Ford-Fulkerson’s Method
1
The procedure augment(f, P) maintains the two conditions:
for every e ∈ E: 0 ≤ f(e) ≤ c(e) (capacity conditions) for every v ∈ V \ {s, t}:
f(e) =
f(e). (conservation conditions)
2
When Ford-Fulkerson’s Method terminates, val(f) is maximized
3
Ford-Fulkerson’s Method will terminate
SLIDE 22 22/77
- Def. An s-t cut of G = (V, E) is a pair (S ⊆ V, T = V \ S)
such that s ∈ S and t ∈ T.
- Def. The cut value of an s-t cut is
c(S, T) :=
c(e).
- Def. Given an s-t flow f and an s-t cut (S, T), the net flow
sent from S to T is f(S, T) :=
f(e) −
f(e).
SLIDE 23 23/77
s t a b c d 6/16 5 / 1 3 6/12 4 / 9 9/14 5 / 7 7/20 4/4 / 4 G
c(S, T) = 14 + 12 = 26 f(S, T) = 9 + 6 − 4 = 11
S T
- Obs. f(S, T) ≤ c(S, T) s-t cut (S, T).
- Obs. f(S, T) = val(f) for any s-t flow f and any s-t cut
(S, T). Coro. val(f) ≤ min
s-t cut (S,T) c(S, T) for every s-t flowf.
SLIDE 24 24/77
Coro. val(f) ≤ min
s-t cut (S,T) c(S, T) for every s-t flowf.
We will prove Main Lemma The flow f found by the Ford-Fulkerson’s Method satisfies val(f) = c(S, T) for some s-t cut (S, T). Corollary and Main Lemma implies Maximum Flow Minimum Cut Theorem sup
s-t flow f
val(f) = min
s-t cut (S,T) c(S, T).
SLIDE 25 25/77
Maximum Flow Minimum Cut Theorem sup
s-t flow f
val(f) = min
s-t cut (S,T) c(S, T).
s t a b d c 12/12 11/14 0/9 0/4 7 / 7 12/16 11/13 19/20 4/4
SLIDE 26 26/77
Main Lemma The flow f found by the Ford-Fulkerson’s Method satisfies val(f) = c(S, T) for some s-t cut (S, T). Proof of Main Lemma. When algorithm terminates, no path from s to t in Gf, What can we say about Gf? There is a s-t cut (S, T), such that there are no edges from S to T For every e = (u, v) ∈ E, u ∈ S, v ∈ T, we have f(e) = c(e) For every e = (u, v) ∈ E, u ∈ T, v ∈ S, we have f(e) = 0 Thus, val(f) = f(S, T) =
f(e) −
f(e) =
c(e) = c(S, T).
SLIDE 27 27/77
Correctness of Ford-Fulkerson’s Method
1
The procedure augment(f, P) maintains the two conditions:
for every e ∈ E: 0 ≤ f(e) ≤ c(e) (capacity conditions) for every v ∈ V \ {s, t}:
f(e) =
f(e). (conservation conditions)
2
When Ford-Fulkerson’s Method terminates, val(f) is maximized
3
Ford-Fulkerson’s Method will terminate
SLIDE 28
28/77
Ford-Fulkerson’s Method will Terminate
Intuition: In every iteration, we increase the flow value by some amount There is a maximum flow value So the algorithm will finally reach the maximum value However, the algorithm may not terminate if some capacities are irrational numbers. (“Pathological cases”)
SLIDE 29
29/77
Lemma Ford-Fulkerson’s Method will terminate if all capacities are integers. Proof. The maximum flow value is finite (not ∞). In every iteration, we increase the flow value by at least 1. So the algorithm will terminate. Integers can be replaced by rational numbers.
SLIDE 30 30/77
Correctness of Ford-Fulkerson’s Method
1
The procedure augment(f, P) maintains the two conditions:
for every e ∈ E: 0 ≤ f(e) ≤ c(e) (capacity conditions) for every v ∈ V \ {s, t}:
f(e) =
f(e). (conservation conditions)
2
When Ford-Fulkerson’s Method terminates, val(f) is maximized
3
Ford-Fulkerson’s Method will terminate
SLIDE 31 31/77
Outline
1
Network Flow
2
Ford-Fulkerson Method Correctness of Ford-Fulkerson’s Method Running Time of Ford-Fulkerson-Type Algorithm
3
Applications of Network-Flow Single Commodity Flow with Multiple Sources and Sinks s-t Edge-Disjoint Paths Problem Bipartite Matching Problem
SLIDE 32 32/77
Running time of the Generic Ford-Fulkerson’s Algorithm
Ford-Fulkerson(G, s, t, c)
1: let f(e) ← 0 for every e in G 2: while there is a path from s to t in Gf do 3:
let P be any simple path from s to t in Gf
4:
f ←augment(f, P)
5: return f
O(m)-time for 3 and 4 in each iteration Total time = O(m)× number of iterations Assume all capacities are integers, then algorithm may run up to val(f ∗) iterations, where f ∗ is the optimum flow Total time = O(mval(f ∗)) Running time is “Pseudo-polynomial”
SLIDE 33
33/77
The Upper Bound on Running Time Is Tight!
s t a b
2 / 1000 2 / 1000 2 / 1 2 / 1000 0 / 1 Better choices for choosing augmentation paths: Choose the shortest augmentation path Choose the augmentation path with the largest bottleneck capacity
SLIDE 34 34/77
Choosing Augmenting Path with Largest Bottleneck Capacity
Idea: find the augmenting path from s to t with the largest bottleneck capacity Assumption: Capacities are integers between 1 and C capacity-scaling(G, s, t, c)
1: let f(e) ← 0 for every e in G 2: ∆ ← largest power of 2 which is at most C 3: while ∆ ≥ 1 do 4:
while while there exists an augmenting path P with bottleneck capacity at least ∆ do
5:
f ←augment(f, P)
6:
∆ ← ∆/2
7: return f
SLIDE 35 35/77
- Obs. The outer while loop repeats 1 + ⌊log2 C⌋ times.
Lemma At the beginning of ∆-scale phase, the value of the max-flow is at most val(f) + 2m∆. Each augmentation increases the flow value by at least ∆ Thus, there are at most 2m augmentations for ∆-scale phase. Theorem The number of augmentations in the capacity-scaling max-flow algorithm is at most O(m log C).
- Coro. Running time of capacity-scaling max-flow algorithm is
polynomial.
SLIDE 36 36/77
Outline
1
Network Flow
2
Ford-Fulkerson Method Correctness of Ford-Fulkerson’s Method Running Time of Ford-Fulkerson-Type Algorithm
3
Applications of Network-Flow Single Commodity Flow with Multiple Sources and Sinks s-t Edge-Disjoint Paths Problem Bipartite Matching Problem
SLIDE 37
37/77
Applications of Network-Flow
Many problems can be reduced to the network-flow problem. single commodity flow with multiple sources and sinks s-t disjoint paths bipartite graph matching preemptive-scheduling of jobs graph orientation and densest subgraph load balance For each problem, we have two aspects: The problem can be solved efficiently. maximum-flow-minimum-cut theorem: dual structure that gives a witness on the optimality of a solution.
SLIDE 38 38/77
Outline
1
Network Flow
2
Ford-Fulkerson Method Correctness of Ford-Fulkerson’s Method Running Time of Ford-Fulkerson-Type Algorithm
3
Applications of Network-Flow Single Commodity Flow with Multiple Sources and Sinks s-t Edge-Disjoint Paths Problem Bipartite Matching Problem
SLIDE 39 39/77
Single Commodity Flow with Multiple Sources and Sinks Input: digraph G = (V, E) with many sources S ⊆ V and many sinks T ⊆ V
no edges enter S, no edges leave T
edge capacity c(e) ∈ R>0 for every e ∈ E Output: a maximum value flow f from S to T
s3 s2 s1 t2 t3 t4 t5 t1 3 5 8 S T
SLIDE 40 40/77
S-T Flow
An S-T flow is a function f : E → R such that for every e ∈ E: 0 ≤ f(e) ≤ c(e) (capacity conditions) for every v ∈ V \ (S ∪ T):
f(e) =
f(e). (conservation conditions) The value of a flow f is val(f) =
f(e).
SLIDE 41 41/77
S-T Flow
s3 s2 s1 t2 t3 t4 t5 t1 3 5 8 S T
SLIDE 42
42/77
“Single Commodity Flow with Multiple Sources and Sinks” Reason for “Single Commodity” there is only one commodity sending a flow from any source to any sink is acceptable
SLIDE 43 43/77
Reduction of Problem to s-t Maximum Flow
s3 s2 s1 t2 t3 t4 t5 t1 3 5 8 S T ∞ ∞ ∞ super source s t super sink ∞ ∞ ∞ ∞ ∞
create a super-source s and super-sink t add edges of capacity ∞ from s to S add edges of capacity ∞ from T to t not hard to see that the reduction works
SLIDE 44 44/77
Dual Structure for Problem
s3 s2 s1 t2 t3 t4 t5 t1 3 5 8 S T A B
MFMC theorem: maximum flow = value of minimum cut (A, B), s ∈ A, t ∈ B (A, B) can not cut new edges, since they have capacity ∞ So, S ⊆ A, T ⊆ B
SLIDE 45 45/77
Dual Structure for Problem
s3 s2 s1 t2 t3 t4 t5 t1 3 5 8 S T A B
Lemma The value of the maximum flow is equal to the minimum value of (A, B), over all cuts (A, B) such that S ⊆ A and T ⊆ B.
SLIDE 46 46/77
Unlimited Supplies and Demands
s3 s2 s1 t2 t3 t4 t5 t1 S T
each source si ∈ S is a supply node each sink ti ∈ T is a demand node every supply node has unlimited amount of commodity, every demand node has unlimited demand for the commodity.
SLIDE 47 47/77
Variant: Limited Supplies and Demands
s3 s2 s1 t2 t3 t4 t5 t1 S T u1 = 10 u2 = 40 u3 = 30 d1 = 20 d2 = 5 d3 = 15 d4 = 30 d5 = 10
every si can supply ui ∈ R>0 units of commodity (ui is called the supply for si) every sink ti di ∈ R>0 units of commodity (di is called the demand for ti) assume
si∈S ui = ti∈T di
Goal: decide if all the demands can be satisfied
SLIDE 48 48/77
Reduction to s-t Network Flow
s3 s2 s1 t2 t3 t4 t5 t1 S T s t 10 40 30 20 5 15 30 10
add a super-source s and a super-sink t add edges from s to S and from T to t the capacity of edge (s, si) is ui the capacity of edge (ti, t) is di decide if there is a flow that saturates all the new (red) edges
SLIDE 49 49/77
Dual structure to the Problem
s3 s2 s1 t2 t3 t4 t5 t1 S T s t 10 40 30 20 5 15 30 10
MFMC: the instance is infeasible if and only if there is a s-t cut (A, B) of value strictly less than
i si = i ti
Now we do not have S ⊆ A, T ⊆ B any more.
SLIDE 50 50/77
Dual structure to the Problem
s3 s2 s1 t2 t3 t4 t5 t1 S T s t 10 40 30 20 5 15 30 10
A B
cut value =
si∈S∩B ui + ti∈T∩A di + Q.
cut value <
si∈S ui = ti∈T di iff
ui +
+Q <
ui
SLIDE 51 51/77
Dual structure to the Problem
s3 s2 s1 t2 t3 t4 t5 t1 S T
A B
ui +
di + Q <
ui ⇔
di + Q <
ui ⇔ Q <
ui −
di
SLIDE 52 52/77
Dual structure to the Problem
s3 s2 s1 t2 t3 t4 t5 t1 S T
A B
Q <
ui −
di. Meaning: “the capacity going out of A is smaller than the net supply inside A”
SLIDE 53 53/77
Dual structure to the Problem
s3 s2 s1 t2 t3 t4 t5 t1 S T
A B
Lemma The instance is infeasible, if and only if there exists a cut (A, B) of the graph, such that the total capacity of edges going out of A is strictly less than the total supply in A, minus the total demand in A.
SLIDE 54
54/77
The reduction only works for single-commodity flow problem. Multi-Commodity Flow We have many pairs (s1, t1), (s2, t2), ..., (sk, tk). Each pair corresponds to one commodity. si needs to send di units of commodity i to ti. Goal : decide if we can satisfy all the demands. We can not reduce the problem to s-t network flow. Q: Why the reduction we used before (i.e, creating a super-source s and a super-sink t) fails? A: In the resulting flow, we may send a flow from si to some tj for j = i.
SLIDE 55 55/77
Outline
1
Network Flow
2
Ford-Fulkerson Method Correctness of Ford-Fulkerson’s Method Running Time of Ford-Fulkerson-Type Algorithm
3
Applications of Network-Flow Single Commodity Flow with Multiple Sources and Sinks s-t Edge-Disjoint Paths Problem Bipartite Matching Problem
SLIDE 56
56/77
s-t Edge Disjoint Paths Input: a directed (or undirected) graph G = (V, E) and s, t ∈ V Output: the maximum number of edge-disjoint paths from s to t in G
s t
SLIDE 57
57/77
Solving the maximum flow problem, where all capacities are 1 All flow values are integral (i.e, either 0 or 1) From flow to disjoint paths find an arbitrary s → t path where all edges have flow value 1 change the flow values of the path to 0 and repeat
s t
SLIDE 58
58/77
Theorem The maximum number of edge disjoint paths from s to t equals the minimum value of an s-t cut (S, T).
s t
SLIDE 59
59/77
s-t Edge Disjoint Paths in Undirected Graphs
s t
an undirected edge → two anti-parallel directed edges. Solving the s-t maximum flow problem in the directed graph Convert the flow to paths Issue: both e = (u, v) and e′ = (v, u) are used Fix: if this happens we change f(e) = f(e′) = 0
SLIDE 60
60/77
Menger’s Theorem
Menger’s Theorem In an undirected graph, the maximum number of edge-disjoint paths between s to t is equal to the minimum number of edges whose removal disconnects s and t.
s t
s-t connectivity measures how well s and t are connected.
SLIDE 61
61/77
Global Min-Cut Problem Input: a connected graph G = (V, E) Output: the minimum number of edges whose removal will disconnect G
SLIDE 62 62/77
Solving Global Min-Cut Using Maximum Flow
1: let G′ be the directed graph obtained from G by replacing
every edge with two anti-parallel edges
2: for every pair s = t of vertices do 3:
- btain the minimum cut separating s and t in G, by
solving the maximum flow instance with graph G′,source s and sink t
4: output the smallest minimum cut we found
Need to solve Θ(n2) maximum flow instances Can we do better? Hint: only need to enumerate t
SLIDE 63 63/77
Outline
1
Network Flow
2
Ford-Fulkerson Method Correctness of Ford-Fulkerson’s Method Running Time of Ford-Fulkerson-Type Algorithm
3
Applications of Network-Flow Single Commodity Flow with Multiple Sources and Sinks s-t Edge-Disjoint Paths Problem Bipartite Matching Problem
SLIDE 64 64/77
Bipartite Graphs
- Def. A graph G = (V, E) is bipartite if the vertices V can be
partitioned into two subsets L and R such that every edge in E is between a vertex in L and a vertex in R.
L R
SLIDE 65 65/77
- Def. Given a bipartite graph G = (L ∪ R, E), a matching in G
is a set M ⊆ E of edges such that every vertex in V is an endpoint of at most one edge in M. Maximum Bipartite Matching Problem Input: bipartite graph G = (L ∪ R, E) Output: a matching M in G of the maximum size L R
SLIDE 66 66/77
Reduce Maximum Bipartite Matching to Maximum Flow Problem
t s
1 ∞
L R
1 1 1 1 1 1 1 1 1 1 1 ∞ ∞ ∞
SLIDE 67
67/77
Reduce Maximum Bipartite Matching to Maximum Flow Problem
Create a digraph G′ = (L ∪ R ∪ {s, t}, E′) with capacity c : E′ → R≥0:
Add a source s and a sink t Add an edge from s to each vertex u ∈ L of capacity 1 Add an edge from each vertex v ∈ R to t of capacity 1 Direct all edges in E from L to R, and assign ∞ capacity (or capacity 1) to them
Compute the maximum flow from s to t in G′ The maximum flow gives a matching Running time:
Ford-Fulkerson: O(m × max flow value) = O(mn). Hopcroft-Karp: O(mn1/2) time
SLIDE 68 68/77
Lemma Size of max matching = value of max flow in G′ Proof. ≤. Given a maximum matching M ⊆ E, send a flow along each edge e ∈ M and thus we have a flow of value |M|.
L R
t s
1 ∞
L R
1 1 1 1 1 1 1 1 1 1 1 ∞ ∞ ∞
SLIDE 69 69/77
Lemma Size of max matching = value of max flow in G′ Proof. ≥. The maximum flow f in G′ is integral since all capacities are integral Let M to be the set of edges e from L to R with f(e) = 1 M is a matching of size that equals to the flow value
t s
1 ∞
L R
1 1 1 1 1 1 1 1 1 1 1 ∞ ∞ ∞
L R
SLIDE 70 70/77
Perfect Matching
- Def. Given a bipartite graph G = (L ∪ R, E) with |L| = |R|, a
perfect matching M of G is a matching such that every vertex v ∈ L ∪ R participates in exactly one edge in M. Assuming |L| = |R| = n, when does G = (L ∪ R, E) not have a perfect matching?
L R L R N(X) X
For X ⊆ L, define N(X) = {v ∈ R : ∃u ∈ X, (u, v) ∈ E} |N(X)| < X for some X ⊆ L = ⇒ no perfect matching
SLIDE 71
71/77
Hall’s Theorem Let G = (L ∪ R, E) be a bipartite graph with |L| = |R|. Then G has a perfect matching if and only if |N(X)| ≥ |X| for every X ⊆ L. Proof. = ⇒. If G has a perfect matching, then vertices matched to X ⊆ N(X); thus |N(X)| ≥ |X|.
SLIDE 72 72/77
Hall’s Theorem Let G = (L ∪ R, E) be a bipartite graph with |L| = |R|. Then G has a perfect matching if and only if |N(X)| ≥ |X| for every X ⊆ L. Proof. ⇐ =. Contrapositive: if no perfect matching, then ∃X ⊆ L, |N(X)| < |X| Consider the network flow instance There is a s-t cut (S, T) of value at most n − 1 Define Ls, Lt, Rs, Rt as in figure
S T s t
SLIDE 73 73/77
Hall’s Theorem Let G = (L ∪ R, E) be a bipartite graph with |L| = |R|. Then G has a perfect matching if and only if |N(X)| ≥ |X| for every X ⊆ L. Proof. ⇐ =. Contrapositive: if no perfect matching, then ∃X ⊆ L, |N(X)| < |X| No edges from Ls to Rt, since their capacities are ∞ c(S, T) = |Lt| + |Rs| < n |N(Ls)| ≤ |Rs| < n − |Lt| = |Ls|.
S T s t
SLIDE 74
74/77
Hall’s Theorem Let G = (L ∪ R, E) be a bipartite graph with |L| = |R|. Then G has a perfect matching if and only if |N(X)| ≥ |X| for every X ⊆ L. Exercise: Let G = (L ∪ R, E) be a bipartite graph with |L| ≤ |R|. Then G has a matching that matches all vertices in L, if and only if |N(X)| ≥ |X| for every X ⊆ L.
SLIDE 75 75/77
Ford-Fulkerson’s Method Restricted to Bipartite Matching
- Def. Given a matching M in
G = (L ∪ R, E), an augmenting path in G is an path of edges alternating between M and E \ M, where both end vertices are unmatched.
SLIDE 76 76/77
Ford-Fulkerson’s Method Restricted to Bipartite Matching
Bipartite-Matching Algorithm
1: M ← ∅ 2: while ∃ an augmenting path P do 3:
for every edge e ∈ P do
4:
if e ∈ M then
5:
remove e from m
6:
else
7:
add e to M
SLIDE 77
77/77
Other Variants of Bipartite Matching b-matching where an edge can be chosen multiple times b-matching where an edge can be chosen at most once Applications from Bipartite Matching and b-Matching Graph orientation, densest sub-graph Load balancing Preemptive scheduling on a single machine, and on multiple machines