Algorithm II
7. Network Flow II
WU Xiaokun 吴晓堃
xkun.wu [at] gmail
Max-flow and min-cut problems are widely applicable model.
Def. Given an undirected graph G = (V, E), subset of edges M \subseteq E is a matching if each node appears in at most one edge in M.
Max matching. Given a graph G, find a max-cardinality matching.
Def. A graph G is bipartite if the nodes can be partitioned into two subsets L and R such that every edge connects a node in L with a node in R.
Bipartite matching. Given a bipartite graph G = (L \cup R, E), find a max-cardinality matching.
Formulation.
Theorem. 1-1 correspondence between matchings of
cardinality k in G and integral flows of value k in G'.
Pf. \Rightarrow
Theorem. 1-1 correspondence between matchings of
cardinality k in G and integral flows of value k in G'.
Pf. \Leftarrow
Theorem. 1-1 correspondence between matchings of cardinality k in G and integral flows of value k in G'.
Corollary. Can solve bipartite matching problem via
max-flow formulation.
Pf.
What is running time of Ford-Fulkerson algorithms to find a max-cardinality matching in a bipartite graph with |L| = |R| = n?
A. O(m + n)
B. O(mn)
C. O(mn^2)
D. O(m^2n)
B. O(m n C) and C is a constant now.
Def. Given a graph G = (V, E), a subset of edges M \subseteq E is a perfect matching if each node appears in exactly one edge in M.
Q. When does a bipartite graph have a perfect matching?
Structure of bipartite graphs with perfect matchings.
Notation. Let S be a subset of nodes, and let N(S) be the set of nodes adjacent to nodes in S.
Observation. If a bipartite graph G = (L \cup R, E) has a perfect matching,
then |N(S)| \ge |S| for all subsets
S \subseteq L.
Pf. Each node in S has
to be matched to a different node in N(S).
Theorem. [Frobenius 1917, Hall 1935] Let G = (L \cup R, E) be a bipartite graph with |L| = |R|. Then, graph G has a perfect matching iff |N(S)| \ge |S| for all subsets S \subseteq L.
Pf. \Rightarrow This is the previous observation.
Pf. \Leftarrow Suppose G does not have a perfect matching.
L_A = \{2, 4, 5\}
L_B = \{1, 3\}
R_A = \{2', 5'\}
N(L_A) = \{2', 5'\}
Def. Two paths are edge-disjoint if they have no edge in common.
Edge-disjoint paths problem. Given a digraph G = (V, E) and two nodes s and t, find the max number of edge-disjoint s \leadsto t paths.
Ex. Communication networks.
Max-flow formulation. Assign unit capacity to every edge.
Theorem. 1-1 correspondence between k edge-disjoint s
\leadsto t paths in G and
integral flows of value k in G'.
Pf. \Rightarrow Let
P_1, \ldots, P_k be k edge-disjoint s
\leadsto t paths in G.
Max-flow formulation. Assign unit capacity to every edge.
Theorem. 1-1 correspondence between k edge-disjoint s
\leadsto t paths in G and
integral flows of value k in G'.
Pf. \Leftarrow Let
f be an integral flow in G' of value k.
Max-flow formulation. Assign unit capacity to every edge.
Theorem. 1-1 correspondence between k edge-disjoint s \leadsto t paths in G and integral flows of value k in G'.
Corollary. Can solve edge-disjoint paths problem via
max-flow formulation.
Pf.
Def. A set of edges F \subseteq E disconnects t from s if every s \leadsto t path uses at least one edge in F.
Network connectivity. Given a digraph G = (V, E) and two nodes s and t, find min number of edges whose removal disconnects t from s.
Theorem. [Menger 1927] The max number of edge-disjoint s \leadsto t paths equals the min number of
edges whose removal disconnects t from
s.
Pf. \le
Theorem. [Menger 1927] The max number of edge-disjoint s \leadsto t paths equals the min number of
edges whose removal disconnects t from
s.
Pf. \ge
How to find the max number of edge-disjoint paths in an undirected graph?
A. Solve the edge-disjoint paths problem in a
digraph (by replacing each undirected edge with two antiparallel
edges).
B. Solve a max flow problem in an undirected
graph.
C. Both A and B.
D. Neither A nor B.
C. both are fine.
Def. Two paths are edge-disjoint if they have no edge in common.
Edge-disjoint paths problem in undirected graphs. Given a graph G = (V, E) and two nodes s and t, find the max number of edge-disjoint s-t paths.
Max-flow formulation. Replace each edge with two antiparallel edges and assign unit capacity to every edge.
Observation. Two paths P_1 and P_2 may be edge-disjoint in the digraph but not edge-disjoint in the undirected graph.
Lemma. In any flow network, there exists a maximum
flow f in which for each pair of
antiparallel edges e and e': either f(e)
= 0 or f(e') = 0 or both.
Moreover, integrality theorem still holds.
Pf. [ by induction on number of such pairs ]
Max-flow formulation. Replace each edge with two antiparallel edges and assign unit capacity to every edge.
Lemma. In any flow network, there exists a maximum flow f in which for each pair of antiparallel edges e and e': either f(e) = 0 or f(e') = 0 or both. Moreover, integrality theorem still holds.
Theorem. Max number of edge-disjoint s \leadsto t paths = value of max flow.
Pf. Similar to proof in digraphs; use lemma.
Theorem. Given an undirected graph and two nodes s and t, the max number of edge-disjoint s-t paths equals the min number of edges whose removal disconnects s and t.
Theorem. Given an undirected graph and two nonadjacent nodes s and t, the max number of internally node-disjoint s-t paths equals the min number of internal nodes whose removal disconnects s and t.
Theorem. Given a directed graph with two nonadjacent nodes s and t, the max number of internally node-disjoint s \leadsto t paths equals the min number of internal nodes whose removal disconnects t from s.
Which extensions to max flow can be easily modeled?
A. Multiple sources and multiple sinks.
B. Undirected graphs.
C. Lower bounds on edge flows.
D. All of the above.
Def. Given a digraph G = (V, E) with edge capacities c(e) \ge 0 and multiple source nodes and multiple sink nodes, find max flow that can be sent from the source nodes to the sink nodes.
Max-flow formulation.
Claim. 1-1 correspondence between flows in G and G'.
Def. Given a digraph G = (V, E) with edge capacities c(e) \ge 0 and node demands d(v), a circulation is a function f(e) that satisfies:
Max-flow formulation.
Claim. G has circulation iff G' has max flow of value D = \sum_{v: d(v) > 0} d(v) = \sum_{v: d(v) < 0} -d(v)
Integrality theorem. If all capacities and demands
are integers, and there exists a circulation, then there exists one that
is integer-valued.
Pf. Follows from max-flow formulation + integrality
theorem for max flow.
Theorem. Given (V, E, c, d), there does not exist a circulation iff there exists a node partition (A, B) such that \sum_{v \in B} d(v) > cap(A, B).
Pf sketch. Look at min cut in G'.
Def. Given a digraph G = (V, E) with edge capacities c(e) \ge 0, lower bounds l(e) \ge 0, and node demands d(v), a circulation f(e) is a function that satisfies:
Circulation problem with lower bounds. Given (V, E, l, c, d), does there exist a feasible circulation?
Max-flow formulation. Model lower bounds as circulation with demands.
Theorem. There exists a circulation in G iff there exists a circulation in G'. Moreover, if all demands, capacities,
and lower bounds in G are integers,
then there exists a circulation in G
that is integer-valued.
Pf sketch. f(e) is a
circulation in G iff f'(e) = f(e) - l(e) is a circulation in
G'.
Goal. Design a survey that meets following specs, if possible.
Bipartite perfect matching. Special case when c_i = c_i' = p_j = p_j' = 1.
Max-flow formulation. Model as a circulation problem with lower bounds.
Airline scheduling.
“Toy problem”.
Circulation formulation. [to see if c crews suffice]
Theorem. The airline scheduling problem can be
solved in O(k^3 \log k) time.
Pf.
Remark. Can solve in O(k^3) time by formulating as minimum-flow problem.
Remark. We solved a toy version of a real problem.
Real-world problem models countless other factors:
Message.
Image segmentation.
Ex. Separate human from background and reconstruct a new scene.
Foreground / background segmentation.
\sum_{i \in A} a_i + \sum_{j \in B} b_j - \sum_{(i,j) \in E, |A \cap \{i,j\}| = 1} p_{ij}
Formulate as min-cut problem. Issues:
Turn into minimization problem.
\sum_{j \in B} a_j + \sum_{i \in A} b_i + \sum_{(i,j) \in E, |A \cap \{i,j\}| = 1} p_{ij}
Formulate as min-cut problem G' = (V' , E').
Consider min-cut (A, B) in G'.
cap(A,B) = \sum_{j \in B} a_j + \sum_{i \in A} b_i + \sum_{(i,j) \in E, i \in A, j \in B} p_{ij}
Grabcut. [ Rother-Kolmogorov-Blake 2004 ]
Projects with prerequisites.
Project selection problem. Given a set of projects P and prerequisites E, choose a feasible subset of projects to maximize revenue.
Prerequisite graph. Add edge (v, w) if w is a prerequisite for v.
Min-cut formulation.
Claim. (A, B) is min-cut iff A - \{ s \} is an optimal set of projects.
Open-pit mining. [studied since early 1960s]
Q. Which teams have a chance of finishing the season with the most wins?
T | W | L | P | A | B | C | D |
---|---|---|---|---|---|---|---|
A | 83 | 71 | 8 | - | 1 | 6 | 1 |
B | 80 | 79 | 3 | 1 | - | 0 | 2 |
C | 78 | 78 | 6 | 6 | 0 | - | 0 |
D | 77 | 82 | 3 | 1 | 2 | 0 | - |
D is mathematically eliminated.
Remark. This appear to be the only reasoning sports writers aware of.
Q. Which teams have a chance of finishing the season with the most wins?
T | Win | Lose | to Play | A | B | C | D |
---|---|---|---|---|---|---|---|
A | 83 | 71 | 8 | - | 1 | 6 | 1 |
B | 80 | 79 | 3 | 1 | - | 0 | 2 |
C | 78 | 78 | 6 | 6 | 0 | - | 0 |
D | 77 | 82 | 3 | 1 | 2 | 0 | - |
B is mathematically eliminated.
Observation. Answer depends not only on how many games already won and left to play, but on whom they’re against.
Current standings.
Tournament elimination problem. Given the current standings, is there any outcome of the remaining games in which team z finishes with the most (or tied for the most) wins?
Can team 4 finish with most wins?
Theorem. Team 4 not eliminated iff max flow
saturates all edges leaving s.
Pf.
Q. Which teams have a chance of finishing the season with the most wins?
T | Win | Lose | to Play | A | B | C | D | E |
---|---|---|---|---|---|---|---|---|
A | 75 | 59 | 28 | - | 3 | 8 | 7 | 3 |
B | 71 | 63 | 28 | 3 | - | 2 | 7 | 4 |
C | 69 | 66 | 27 | 8 | 2 | - | 0 | 0 |
D | 63 | 72 | 27 | 7 | 7 | 0 | - | 0 |
E | 49 | 86 | 27 | 3 | 4 | 0 | 0 | - |
E is mathematically eliminated.
Theorem. [Hoffman-Rivlin 1967] Team z is eliminated iff there exists a subset T^\ast: w_z + g_z < \frac{w(T^\ast) + g(T^\ast)}{|T^\ast|}.
Pf. \Leftarrow
Pf. \Rightarrow
Pf. \Rightarrow
\begin{aligned} g(S − \{z\}) & > cap(A, B) \\ & = [g(S − \{z\}) - g(T^\ast)] + [\sum_{x \in T^\ast} (w_z + g_z - w_x)] \\ & = [g(S − \{z\}) - g(T^\ast)] + [w(T^\ast) + |T^\ast|(w_z + g_z)] \\ \end{aligned}