You are on page 1of 20

# Maximum Flow Applications Contents

Maximum Flow Applications

Max flow extensions and applications.
s

Disjoint paths and network connectivity. Bipartite matchings. Circulations with upper and lower bounds. Census tabulation (matrix rounding). Airline scheduling. Image segmentation. Project selection (max weight closure). Baseball elimination.

s

s

s

s

s

s

s

Princeton University • COS 423 • Theory of Algorithms • Spring 2001 • Kevin Wayne

2

Disjoint Paths
Disjoint path network: G = (V, E, s, t).
s

Disjoint Paths
Disjoint path network: G = (V, E, s, t).
s

Directed graph (V, E), source s, sink t. Two paths are edge-disjoint if they have no arc in common.

Directed graph (V, E), source s, sink t. Two paths are edge-disjoint if they have no arc in common.

s

s

Disjoint path problem: find max number of edge-disjoint s-t paths.
s

Disjoint path problem: find max number of edge-disjoint s-t paths.

Application: communication networks.

2

5

2

5

s

3

6

t

s

3

6

t

4

7

4

7

3

4

Disjoint Paths
Max flow formulation: assign unit capacity to every edge.
1 1 s 1 1 1 1 1 1 1 1 1 1

Disjoint Paths
Max flow formulation: assign unit capacity to every edge.
1 1 t s 1 1 1 1 1 1 1 1 1 1

1 1

1 1 t

Theorem. There are k edge-disjoint paths from s to t if and only if the max flow value is k. Proof. ⇒
s

Theorem. There are k edge-disjoint paths from s to t if and only if the max flow value is k. Proof. ⇐
s

Suppose there are k edge-disjoint paths P1, . . . , Pk. Set f(e) = 1 if e participates in some path Pi ; otherwise, set f(e) = 0. Since paths are edge-disjoint, f is a flow of value k.

s

Suppose max flow value is k. By integrality theorem, there exists {0, 1} flow f of value k. Consider edge (s,v) with f(s,v) = 1. – by conservation, there exists an arc (v,w) with f(v,w) = 1 – continue until reach t, always choosing a new edge Produces k (not necessarily simple) edge-disjoint paths.
6

s

s

s

5

Network Connectivity
Network connectivity network: G = (V, E, s, t) .
s

Network Connectivity
Network connectivity network: G = (V, E, s, t) .
s

Directed graph (V, E), source s, sink t. A set of edges F ⊆ E disconnects t from s if all s-t paths uses at least on edge in F.

Directed graph (V, E), source s, sink t. A set of edges F ⊆ E disconnects t from s if all s-t paths uses at least on edge in F.

s

s

Network connectivity: find min number of edges whose removal disconnects t from s.
2 5

Network connectivity: find min number of edges whose removal disconnects t from s.
2 5

s

3

6

t

s

3

6

t

4

7

4

7

7

8

s s Suppose max number of edge-disjoint paths is k. Proof. Let F be set of edges going from S to T. the number of edgedisjoint paths is at most k. All s-t paths use at least one edge of F. The max number of edge-disjoint s-t paths is equal to the min number of arcs whose removal disconnects t from s. Max matching: find a max cardinality matching. ⇐ s Suppose the removal of F ⊆ E disconnects t from s. Then max flow value is k. Proof. and definition of cut implies F disconnects t from s. s s s s 2 5 2 5 s 3 6 t s 3 6 t 4 7 4 7 11 12 . s 2 5 2 5 2 5 2 5 s 3 6 t s 3 6 t s 3 6 t s 3 6 t 4 7 4 7 9 4 7 4 7 10 Disjoint Paths and Network Connectivity Menger’s Theorem (1927). s Input: undirected graph G = (V. |F| = k. Hence. Max-flow min-cut ⇒ cut (S.Disjoint Paths and Network Connectivity Menger’s Theorem (1927). ⇒ s Matching Matching. and |F| = k. T) of capacity k. The max number of edge-disjoint s-t paths is equal to the min number of arcs whose removal disconnects t from s. The max number of edge-disjoint s-t paths is equal to the min number of arcs whose removal disconnects t from s. M ⊆ E is a matching if each node appears in at most edge in M. E). Disjoint Paths and Network Connectivity Menger’s Theorem (1927).

3 . t}. Direct all arcs from L to R. E). 4-5’ 2 2’ Matching 1-1’. E’ ).Bipartite Matching Bipartite matching. s . Max matching: find a max cardinality matching. Max matching: find a max cardinality matching. Consider flow that sends 1 unit along each of 3 paths: s .5’ } of cardinality 3. Matching in G of cardinality k induces flow in G’ of value k.1 .1’. f is a flow.1’ .t. Add sink t.4 . 2-2’.t. bipartite graph G = (L ∪ R.2’. 4 . Given matching M = { 1 . s Create directed graph G’ = (L ∪ R ∪ {s. and unit capacity arcs from each node in R to t. 4-4’ 3 3’ 3 3’ 4 4’ 4 4’ L 5 5’ R 13 L 5 5’ R 14 Bipartite Matching Max flow formulation.2’ . s Bipartite Matching Bipartite matching. Input: undirected. E). 3-3’. bipartite graph G = (L ∪ R. and has cardinality 3. M ⊆ E is a matching if each node appears in at most edge in M. s Input: undirected. and unit capacity arcs from s to each node in L.t. s Bipartite Matching: Proof of Correctness Claim. Add source s. s s s s s 1 ∞ 1’ 1 1’ 1 ∞ 1’ 1 2 2’ 1 2 2’ 1 2 2’ 1 s 3 3’ t 3 3’ s 3 3’ t 4 4’ 4 4’ 4 4’ L 5 5’ R 15 5 5’ 5 5’ 16 .3 . 3-1’. and give infinite (or unit) capacity. s .5’ . s s s s 1 1’ 1 1’ 2 2’ Matching 1-2’. M ⊆ E is a matching if each node appears in at most edge in M.

s By integrality theorem. has a perfect matching. A matching M ⊆ E is perfect if each node appears in exactly one edge in M. then |N(X)| ≥ |X| for every X ⊆ L. s Input: undirected. R ∪ t) Input: undirected graph G = (V. Consider M = set of edges from L to R with f(e) = 1. E) be a bipartite graph with |L| = |R|. Let G = (L ∪ R. s Each node in X has to be matched to a different node in N(X). If a bipartite graph G = (L ∪ R. either s (i) G either has a perfect matching. E). Observation. 1}-valued flow f of value k. 4 4’ 4 4’ 5 5’ 5 5’ 17 18 Perfect Matching Let X be a subset of nodes. s s Perfect bipartite matching. and let N(X) be the set of nodes adjacent to nodes in x. there exists {0. E). N(X) = {2’. s Perfect Matching Hall’s Theorem. s Perfect Matching Perfect matching. |L| = |R| = n. 1 1’ 1 1’ 2 2’ 2 2’ No perfect matching: X = {2. Can determine if bipartite graph has perfect matching by running matching algorithm. Then. Flow f of value k in G’ induces matching of cardinality k in G.Bipartite Matching: Proof of Correctness Claim. 3 3’ 3 3’ 4 4’ 4 4’ L 5 5’ R 19 L 5 5’ R 20 . or (ii) There exists a subset X ⊆ L such that |N(X)| < |X|. E). 5}. – each node in L and R participates in at most one edge in M – |M| = k: consider cut (L ∪ s. bipartite graph G = (L ∪ R. 5’}. 1 ∞ 1’ 1 1’ s 1 2 2’ 1 2 2’ Is there an easy way to convince someone that a bipartite graph does not have a perfect matching? s 3 3’ t 3 3’ s Need good characterization of such graphs. 4.

1 s s s 1 ∞ 1’ 1 2 2’ 1 LS = {2. Then. s Perfect Matching Proof. w) ∈ E: v ∈ S ⇒ w ∈ S. 4 4’ 3 3’ s 4 4’ 5 5’ 5 5’ 23 G’ 24 . T) be min cut. s Dancing Problem (k-Regular Bipartite Graph) Mathematical reformulation: does every k-regular bipartite graph have a perfect matching? Slick solution: s Exclusive Ivy league party attended by n men and n women. LT = L ∩ S . RS = R ∩ S. Is it possible to arrange a dance so that each man dances with a different woman that he knows? 1 1’ s s Size of max matching is equal to max flow in network G’. T) < n. Suppose G does not have perfect matching. Consider following flow: flow f 1 s s s Mathematical reformulation: does every k-regular bipartite graph have a perfect matching? 2 2’ s  1 / k if (v. 3} RS = {2’. Acquaintances are mutual. T) < n. w) ∈ E 1 if v = s  f (v . Define X = LS = L ∩ S. T) be min cut. (min cut can’t use ∞ arcs) – N(LS ) ⊆ RS ⇒ |N(LS )| ≤ |RS |. Integrality theorem ⇒ integral flow of value n ⇒ perfect matching. 5’} 2 1 2’ ∞ 1 ∞ 1’ 1 3’ 4’ t s 3 3’ t s 4 1 3 4 4’ S 5 5’ 21 5 5’ 1 22 Dancing Problem (k-Regular Bipartite Graph) Dancing problem. Suppose G does not have perfect matching. Each woman knows exactly k men. Let (S. By max-flow min-cut. Then. there exists a subset X ⊆ L such that |N(X)| < |X|.Perfect Matching Proof. Each man knows exactly k women. 5} LT = {1. s Let (S. cap(S. T) = | LT | + |RS | ⇒ |RS | < |LS |. there exists a subset X ⊆ L such that |N(X)| < |X|. w ) =  if w = t 1 0 otherwise  s 1/k 1 1’ 1 1 2 2’ 1 1 3 3’ t f is a flow and | f | = n. cap(S. For all arcs (v. By max-flow min-cut. 4. cap(S.

a vertex cover is a subset of vertices C ⊆ V such that: s Every arc (v. w) ∈ E has either v ∈ C or w ∈ C or both. Then. 1 1’ 1 1’ 2 2’ 2 2’ C = { 3. 4-5’ } |M| = 3 2 2’ M* = { 1-1'. Let M be a matching. and let C be a vertex cover. 4. 1’. w) ∈ E has either v ∈ C or w ∈ C or both. 2-2'. 1'.Vertex Cover Given an undirected graph G = (V. 5-5' } |M*| = 4 3 3’ C* = { 3. Every arc (v. 5. |M| ≤ |C|. 1’. 5' } |C*| = 4 3 3’ 4 4’ 4 4’ L 5 5’ 27 5 5’ R 28 . 3-1’. E). E). 1 1’ 2 2’ M = { 1-2’. undirected graph the max cardinality of a matching is equal to the min cardinality of a vertex cover. a vertex cover is a subset of vertices C ⊆ V such that: s Every arc (v. E). 5’ } |C| = 4 4 4’ 4 4’ 5 5’ 25 5 5’ 26 Vertex Cover Given an undirected graph G = (V. a vertex cover is a subset of vertices C ⊆ V such that: s Vertex Cover Given an undirected graph G = (V. a vertex cover is a subset of vertices C ⊆ V such that: s Vertex Cover: König-Egerváry Theorem Given an undirected graph G = (V. 2’. 1 1’ König-Egerváry Theorem: In a bipartite. Every arc (v. s Each vertex can cover at most one edge in any matching. 2’ } |C| = 5 3 3’ 3 3’ C = { 3. 2'. w) ∈ E has either v ∈ C or w ∈ C or both. E). Observation. 3-3'. w) ∈ E has either v ∈ C or w ∈ C or both.

s Claim 1.n1/2. Each phase of normal augmentations takes O(m) time. w) ∈ E – v ∈ LS. undirected graph. RS = R ∩ S. LT = L ∩ T. |C*| = |M*|. | f | ≥ | f *| . and C* = LT ∪ RS . T) be min cut. or (ii) at most one outgoing arc. the sizes of max matching and min vertex cover are equal. then so is Gf. Use max flow formulation. s Vertex Cover: Proof of König-Egerváry Theorem König-Egerváry Theorem: In a bipartite. Special augmentation: length of shortest path strictly increases. C* is a vertex cover. RT = R ∩ T . w ∈ RT impossible since infinite capacity – thus. LT = L ∩ T. s s s Seems to indicate "more clever" algorithms are not as good as we first thought. 32 s s 31 . flow is optimal. T) – only arcs of form (s. assuming f is {0. Capacity scaling: O(m2 log U ) = O(m2).Vertex Cover: Proof of König-Egerváry Theorem König-Egerváry Theorem: In a bipartite. and let (S. RS = R ∩ S. Use max flow formulation. s 30 Bipartite Matching and Vertex Cover Which max flow algorithm to use for bipartite matching / vertex cover? s Unit Capacity Simple Networks Unit capacity simple network. 1} flow. L2. s Suffices to find matching M* and cover C* such that |M*| = |C*|.just need more clever analysis! For bipartite matching. s Theorem. After at most n1/2 additional augmentations. T) be min cut. Shortest augmenting path: O(m n2). If G is simple unit capacity. C* is a vertex cover. shortest augmenting path algorithm runs in O(m n1/2) time. and let (S. undirected graph. No . After at most n1/2 phases. s L1. the sizes of max matching and min vertex cover are equal. T) – |M*| = u(S. Claim 2. – consider (v. T) = |LT| + |RS| = |C*|. Every node has either: (i) at most one incoming arc. Shortest augmenting path algorithm runs in O(m n1/2) time. Every arc capacity is one. v ∈ LT or w ∈ RS or both 29 s Claim 1. s Shortest augmenting path algorithm. 1 s 1 Suffices to find matching M* and cover C* such that |M*| = |C*|. L3. and C* = LT ∪ RS . s Normal augmentation: length of shortest path doesn’t change. v) or (w. 1 1 s ∞ 1’ s ∞ 1’ 2 2’ 1 t s 2 2’ 1 t 3 4 3’ 4’ 5’ 3 4 3’ 4’ 5’ s 5 Define LS = L ∩ S. s 5 Define LS = L ∩ S. t) contribute to cap(S. RT = R ∩ T . s 1 1 1 Generic augmenting path: O( m |f *| ) = O(mn). – max-flow min-cut theorem ⇒ |M*| = cap(S.

s Start at s. delete node and go to previous node Start at s. delete node and go to previous node Augment Delete node and retreat Level graph 33 Level graph 34 Unit Capacity Simple Networks Lemma 1. advance along an arc in LG until reach t or get stuck. – if reach t. s Unit Capacity Simple Networks Lemma 1. – if reach t. delete node and go to previous node Start at s. – if reach t. delete node and go to previous node Augment STOP Length of shortest path has increased. Level graph 35 Level graph 36 .Unit Capacity Simple Networks Lemma 1. advance along an arc in LG until reach t or get stuck. augment and delete ALL arcs on path – if get stuck. augment and delete ALL arcs on path – if get stuck. Phase of normal augmentations takes O(m) time. Phase of normal augmentations takes O(m) time. s Start at s. advance along an arc in LG until reach t or get stuck. augment and delete ALL arcs on path – if get stuck. Phase of normal augmentations takes O(m) time. advance along an arc in LG until reach t or get stuck. – if reach t. Phase of normal augmentations takes O(m) time. s Unit Capacity Simple Networks Lemma 1. augment and delete ALL arcs on path – if get stuck.

pred[v] ← nil delete v from LG UNTIL (v = s) RETURN f 37 38 Start at s. E. delete node and go to previous node O(m) running time. S := {v : l(v) < h} ∪ {v : l(v) = h and v has ≤ 1 outgoing residual arc}. capf (S. s Unit Capacity Simple Networks AdvanceRetreat(V. P) update LG v ← s. – if reach t. pred[v] ← nil REPEAT WHILE (there exists (v. Residual arcs Level graph s Level graph has more than n1/2 levels. augment and delete ALL arcs on path – if get stuck.n1/2.n1/2. After at most n1/2 phases. | f | ≥ | f *| .n1/2. | f | ≥ | f *| . length of shortest augmenting path is > After n1/2 phases. Let 1 ≤ h ≤ n1/2 be layer with min number of nodes: |Vh| ≤ n1/2. T) ≤ |Vh| ≤ n1/2 ⇒ | f | ≥ | f *| . After at most n1/2 phases. advance along an arc in LG until reach t or get stuck. Let 1 ≤ h ≤ n1/2 be layer with min number of nodes: |Vh| ≤ n1/2. length of shortest augmenting path is > n1/2. s. s After n1/2 phases.Unit Capacity Simple Networks Lemma 1. f. n1/2. v ← w IF (v = t) P ← path defined by pred[] f ← augment(f. since each arc traversed at most once – O(1) per node deletion s advance augment retreat Unit Capacity Simple Networks Lemma 2.w) ∈ LG) pred[w] ← v. Phase of normal augmentations takes O(m) time. s s s s s Level graph V0 V1 Vh Vn1/2 V0 39 V1 Vh Vn1/2 40 . Level graph has more than n1/2 levels. s Unit Capacity Simple Networks Lemma 2. – O(m) to create level graph – O(1) per arc. t) ARRAY pred[v ∈ V] LG ← level graph of Gf v ← s.

. 43 44 . What are the myriad possibilities? Who’s got the edge?" "The hell does he know?" "Apparently not much. wi + ri < wj ⇒ team i eliminated. "See that thing in the paper last week about Einstein? . . then some other team wins one.Baseball Elimination Over on the radio side the producer’s saying. . If Atlanta loses a game. but still eliminated . the other teams win this number or that number. Only reason sports writers appear to be aware of. but also on whom they’re against. Sufficient. s s s s Answer depends not just on how many games already won and left to play. He picked the Dodgers to eliminate the Giants last Friday." s s s 41 42 Baseball Elimination Team i Atlanta Philly New York Montreal Wins wi 83 80 78 77 Losses li 71 79 78 82 To play ri 8 3 6 3 Against = rij Phi NY Mon 1 6 1 0 2 0 0 2 0 Team i Atlanta Philly New York Montreal Baseball Elimination Wins wi 83 80 78 77 Losses li 71 79 78 82 To play ri 8 3 6 3 Against = rij Phi NY Mon 1 6 1 0 2 0 0 2 0 - Atl 1 6 1 Atl 1 6 1 Which teams have a chance of finishing the season with most wins? s Which teams have a chance of finishing the season with most wins? s Montreal eliminated since it can finish with at most 80 wins. . You know. Some reporter asked him to figure out the mathematics of the pennant race. but Atlanta already has 83. one team wins so many of their remaining games. but not necessary! Philly can win 83.

w4 t 2-5 5 4-5 45 46 Baseball Elimination: Max Flow Formulation Theorem. Distinguished team x ∈ X. Capacity on (v. s Baseball Elimination: Explanation for Sports Writers Team i NY Baltimore Boston Toronto Detroit Wins wi 75 71 69 63 49 Losses li 59 63 66 72 86 To play ri 28 28 27 27 27 NY 3 8 7 3 Against = rij Bal Bos Tor 3 2 7 4 8 2 0 0 7 7 0 0 Det 3 4 0 - Integrality theorem ⇒ each remaining game between i and j added to number of wins for team i or team j.Baseball Elimination Baseball elimination problem. t) arcs ensure no team wins too many games. Divvy remaining games so that all teams have ≤ w3 + r3 wins. Is there any outcome of the remaining games in which team x finishes with the most (or tied for the most) wins? Assume team 3 wins all remaining games ⇒ w3 + r3 wins. s s s s s 1-2 1 team 4 can still win this many more games games left 1-4 2 1-5 ∞ ∞ 4 s r24 = 7 2-4 w3 + r3 . 1996 Which teams have a chance of finishing the season with most wins? s ∞ ∞ 4 Detroit could finish season with 49 + 27 = 76 wins. 1-2 1 s team 4 can still win this many more games games left 1-4 2 1-5 AL East: August 30. Team i has won wi games already. s Baseball Elimination: Max Flow Formulation Can team 3 finish with most wins? s Set of teams X. s r24 = 7 2-4 w3 + r3 . Team 3 is not eliminated if and only if max flow saturates all arcs leaving source. Teams i and j play each other rij additional times.w4 t 2-5 5 4-5 47 48 .

Must win at least r(R) = 27 more. 1967). #7 wins 68 R ⊆ X . s Proof idea. Claim. then adding i-j to S decreases capacity of cut Use max flow formulation. Bos. 49 50 s Baseball Elimination: Explanation for Sports Writers Proof of Theorem. j ∈R LB on avg # games won If 64 744 4 8 w( R ) + r ( R) |R| > w x + rx then x is eliminated (by R). Define R = team nodes on source side of min cut = T ∩ S. T ) = r ( X − { x }) − r ( R ) + ∑ ( w x + rx − w i ) i ∈R 1-2 1 team 4 can still win this many more games games left 1-2 1 team 4 can still win this many more games games left 1-4 2 1-4 2 ∞ s ∞ ∞ 4 w3 + r3 . Team x is eliminated if and only if there exists a subset R that eliminates x.w4 t 52 . s s s s r ( X − { x }) > cap( S . and consider min cut (S. Tor} s Have already won w(R) = 278 games.Baseball Elimination: Explanation for Sports Writers Team i NY Baltimore Boston Toronto Detroit Wins wi 75 71 69 63 49 Losses li 59 63 66 72 86 To play ri 28 28 27 27 27 NY 3 8 7 3 Against = rij Bal Bos Tor 3 8 7 2 7 4 2 0 0 7 0 0 Det 3 4 0 - Baseball Elimination: Explanation for Sports Writers Certificate of elimination. and consider min cut (S. w ( R ) := ∑ w i . Detroit could finish season with 49 + 27 = 76 wins. T). ! Average team in R wins at least 305/4 > 76 games. – infinite capacity arcs ensure if i-j ∈ S then i ∈ S and j ∈ S – if i ∈ S and j ∈ S but i-j ∈ T.w4 t 51 r24 = 7 2-4 s r24 = 7 2-4 ∞ 4 w3 + r3 . 1996 Which teams have a chance of finishing the season with most wins? s Theorem (Hoffman-Rivlin. s Baseball Elimination: Explanation for Sports Writers Proof of Theorem. s Use max flow formulation. Bal. i∈R # remaining games r ( R ) := 64 744 4 8 1 ∑ rij . AL East: August 30. Let R = team nodes on source side of min cut. Consider subset R = {NY. i-j ∈ S if and only if i ∈ R and j ∈ R. 2 i . Define R = team nodes on source side of min cut = T ∩ S. T). i-j ∈ S if and only if i ∈ R and j ∈ R. Claim.

T). Node supply and demands d(v). Define R = team nodes on source side of min cut = T ∩ S. 3 3 10 0 4 4 8 11 Capacity Demand Flow 55 56 . – demand if d(v) > 0. |R| Circulation problem: given (V. u. d). Claim. and consider min cut (S. E). T ) = r ( X − { x }) − r ( R ) + ∑ ( w x + rx − w i ) = r ( X − { x }) − r ( R ) − w ( R ) + | R | ( w x + rx ) s i ∈R A circulation is a function f: E → ℜ that satisfies: s For each e ∈ E: For each v ∈ V: s Rearranging terms: e in to v 0 ≤ f(e) ≤ u(e) f (e ) − ∑ f (e ) = d (v ) ∑ e out of v (capacity) (conservation) w x + rx < w( R ) + r ( R) . does there exist a circulation? 53 54 Circulation with Demands A circulation is a function f: E → ℜ that satisfies: s Circulation with Demands A circulation is a function f: E → ℜ that satisfies: (capacity) (conservation) s For each e ∈ E: For each v ∈ V: e in to v 0 ≤ f(e) ≤ u(e) For each e ∈ E: For each v ∈ V: e in to v 0 ≤ f(e) ≤ u(e) (capacity) (conservation) s ∑ f (e ) − e out of v ∑ f (e ) = d (v ) s ∑ f (e ) − e out of v ∑ f (e ) = d (v ) -8 2 -6 6 7 1 7 5 Necessary condition: sum of supplies = sum of demands. Directed graph G = (V. s Circulation with Demands Circulation with demands. supply if d(v) < 0. E.Baseball Elimination: Explanation for Sports Writers Proof of Theorem. v ∈ V. Arc capacities u(e). v : d (v ) > 0 ∑ d (v ) = 4 10 -7 1 7 4 2 6 v : d (v ) < 0 ∑ − d (v ) =: D 6 6 3 9 s Proof: sum conservation constraints for every demand node v. s Use max flow formulation. e ∈ E. transshipment if d(v) = 0 s s s s r ( X − { x }) > cap( S . i-j ∈ S if and only if i ∈ R and j ∈ R.

add arc (s. v) with capacity -d(v). and there exists a circulation. s Circulation with Demands Max flow formulation. there does not exists a circulation if and only if there exists a node partition (A. B). t) with capacity d(v). 6 5 7 8 2 Demand s G’: 7 10 6 3 Given (V. s Circulation with Demands Max flow formulation. v) with capacity -d(v). Add new source s and sink t. 9 – 1 3 4 11 8 s demand by nodes in B exceeds supply of nodes in B plus max capacity of arcs going from A to B 0 10 t 59 Proof idea: look at min cut in G’. s s s s s Demand G: -8 2 -6 5 7 8 2 6 5 Demand G’: 7 7 4 6 7 10 6 3 7 4 6 9 4 10 6 3 9 4 11 -7 1 3 8 1 3 8 10 0 11 10 t 57 0 58 Circulation with Demands Max flow formulation. Moreover. 60 . For each v with d(v) < 0. u. Graph G has circulation if and only if G’ has max flow of value D (saturates all arcs leaving s and entering t). if all capacities and demands are integers. For each v with d(v) > 0. s s Characterization.Circulation with Demands Max flow formulation. t) with capacity d(v). s Add new source s and sink t. add arc (s. For each v with d(v) > 0. add arc (v. B) such that: v ∈B 7 4 6 ∑ d (v ) > u ( A. add arc (v. d). s Graph G has circulation if and only if G’ has max flow of value D (saturates all arcs leaving s and entering t). E. then there exists one that is integer-valued. For each v with d(v) < 0.

d).2 7. and lower bounds in G are integers. there exists a feasible rounding. E.4 Original Data 63 Possible Rounding 64 .2 61 62 Circulation with Demands and Lower Bounds A circulation is a function f: E → ℜ that satisfies: s Matrix Rounding Feasible matrix rounding. Row i sum = ai. v ∈ V. Round each dij.3 0. e ∈ E. column j sum bj. E). For each e ∈ E: For each v ∈ V: l(e) ≤ f(e) ≤ u(e) e out of v (capacity) (conservation) s s ∑ f (e ) − ∑ f (e ) = d (v ) e in to v s A circulation is a function f: E → ℜ that satisfies: s For each e ∈ E: For each v ∈ V: s e in to v ∑ f (e ) − l(e) ≤ f(e) ≤ u(e) ∑ f (e ) = d (v ) e out of v (capacity) (conservation) Idea: model lower bounds with supply / demands. Lower bound d(v) v Capacity 2.8 2.7 6.7 11. is there a circulation? Create network G’. – force flow to make use of certain edges Node supply and demands d(v).24 12. s 3. capacities. ai. u′(e ) = u (e ) − l(e ) d ′(v ) = d (v ) + ∑ l(e ) − e out of v s e in to v ∑ l(e ) Theorem: for any matrix. 9 2 w d(w) Flow Given (V.Circulation with Demands and Lower Bounds Feasible circulation. u. s Circulation with Demands and Lower Bounds A circulation is a function f: E → ℜ that satisfies: s Directed graph G = (V. Theorem. Original application: publishing US Census data. then there is a circulation in G that is integer-valued. u′(e ) = u (e ) − l(e ) d ′(v ) = d (v ) + ∑ l(e ) − e out of v e in to v ∑ l(e ) d(v) + 2 v Capacity 7 w d(w) .l(e) is a circulation in G’.34 10. 16. There exists a circulation in G if and only if there exists a circulation in G’. s ∑ f (e ) − ∑ f (e ) = d (v ) e in to v s s Create network G’. If all demands. l.14 9.6 6.6 3.3 3 10 3 16 7 2 1 10 7 1 7 15 17 13 11 Proof idea: f(e) is a circulation in G if and only if f’(e) = f(e) . bj up or down to integer so that sum of rounded elements in each row (column) equal row (column) sum. s For each e ∈ E: For each v ∈ V: l(e) ≤ f(e) ≤ u(e) e out of v (capacity) (conservation) Given a p x q matrix D = {di j } of real numbers.5 14.4 1. Arc capacities u(e) and lower bounds l(e).5 17.

For each flight i. 1 u3 v3 s s s s s s "Toy problem.7 6. s Note: "threshold rounding" doesn’t work.6 3. ui) with capacity 1. s Matrix Rounding Max flow formulation. 13 11.5 17.9 0. 18 16.35 0.3 1 s Row 3.Matrix Rounding Feasible matrix rounding.35 0. 1 u4 v4 flight is performed 67 same crew can do flights 2 and 4 68 . 4 Column 1’ Theorem: for any matrix. breakdowns One of largest consumers of high-powered algorithmic techniques.2 7." s crew can begin day with any flight 0. Add sink t with demand c. add arc (ui. vi) with lower bound and capacity 1.34 10.05 1. Produces schedules for thousands of routes each day that are efficient in terms of: – equipment usage. include two nodes ui and vi. and arcs (vj.6 6.9 0. Row i sum = ai. Input: list of cities V.4 17.24 12. 15 3 3’ Original Data Possible Rounding 65 Lower bound Upper bound ∞ 66 Airline Scheduling Airline scheduling. 11 t 14. s Airline Scheduling Max flow formulation. 12 10.4 1. 1 v2 0. ti) consists of origin and destination cities.65 0 1 1 0 1 1 1 0 1 1 2 s 12.55 0. crew can end day with any flight 0. s Complex computational problem faced by nation’s airline carriers. if flight j reachable from i. 1 -c s u1 v1 Manage flight crews by reusing them over multiple flights. Flight i: (oi. 17 2 2’ 0. Round each dij.3 0. For each i. and arcs (s. ai. ui) with capacity 1. s Given a p x q matrix D = {di j } of real numbers. and departure time. Travel time t(v.55 0. Integrality theorem ⇒ there always exists feasible rounding! s s s 3. add arc (vi.55 0. crew allocation. 16. column j sum bj. Add source s with demand -c.14 9.7 11. use c crews c t s s s u2 1. Original data provides circulation (all demands 0). there exists a feasible rounding. w) from city v to w. di.35 0. Original application: publishing US Census data. bj up or down to integer so that sum of rounded elements in each row (column) equal row (column) sum.5 14. customer satisfaction – in presence of unpredictable issues like weather. t) with capacity 1.8 2.9 1.

not just 1 day – deadheading has a cost – simultaneously trying to re-work flight schedule and re-optimize fare structure s s s s s Remarks. Find partition (S. s Image Segmentation Foreground / background segmentation. Real problem addresses countless other factors: – union regulations: e. Overall time = O(k4) . Smoothness: if many neighbors of v are labeled foreground. av = likelihood pixel v in foreground. we should be inclined to label v as foreground. s k = number of flights. flight crews can only fly certain number of hours in given interval – need optimal schedule over planning horizon. Divide image into coherent regions.w } = 1 72 71 . s Airline Scheduling: Postmortem Airline scheduling." Message. V = set of pixels. w } ∈ E S I {v . Flow techniques useful for solving airline scheduling problems. O(k2) edges. Arc capacities between 0 and k ⇒ at most k augmentations per max flow computation. At most k crews needed ⇒ solve k max flow problems.. s s s s Goals. in isolation we prefer to label pixel v in foreground. s Central problem in image processing. Running an airline efficiently is a very difficult problem. s Accuracy: if av > bv. – three people standing in front of complex background scene – identify each of three people as coherent objects s Label each pixel in picture as belonging to foreground or background. s Our solution is a generally useful technique for efficient re-use of limited resources but trivializes real airline scheduling problem. and are genuinely used in practice. E = pairs of neighboring pixels. T) that maximizes: v ∈S s s ∑ av + ∑ bv − v ∈T ∑ pvw {v . pvw = separation penalty for labeling one of v and w as foreground.g. and the other as background. O(k) nodes.Airline Scheduling: Running Time Running time. s Can solve in O(k3) time by formulating as "minimum flow problem. We solved toy problem. 70 s s 69 Image Segmentation Image segmentation. bv = likelihood pixel v in background.

get site license for encryption software Set of prerequisites E. s Project Selection Projects with prerequisites. Project v has associated revenue pv. s pvw pvw pvw Maximization. and (v.w } = 1 ∑ pvw s v t bv pvw w 73 74 Image Segmentation Consider min cut (S.Image Segmentation Formulate as min cut problem. w } ∈ E S I {v . w } ∈ E S I {v . No source or sink. – can’t start on e-commerce opportunity unless you’ve got encryption software A subset of projects A ⊆ P is feasible if the prerequisite of every project in A also belongs to A. w ∈T s Precisely the quantity we want to minimize. s s Since v ∈V ∑ a v + ∑ b v is a constant. w ) ∈ E v ∈S . – note if v and w on different sides. T ) = v ∈T ∑ a v + ∑ bv − v ∈S ∑ pvw (v . redesign cs web page – others cost money: upgrade computers. s cap(S . – some projects generate money: create interactive e-commerce interface. pvw counted exactly once s Set P of possible projects. G’ 76 . can’t do project v and unless also do project w. If (v. – for each v ∈ P. v ∈V maximizing v ∈S ∑ a v + ∑ bv − v ∈T ∑ pvw {v . – add two anti-parallel arcs s s s Turn into minimization problem. T) in resulting graph. Undirected graph. – add source to correspond to foreground – add sink to correspond to background Undirected graph. we have w ∈ P s av s v t bv pvw w 75 Project selection (max weight closure) problem: choose a feasible subset of projects to maximize revenue. s Image Segmentation Formulate as min cut problem: G’ = (V’. Maximization. E’).w } = 1 ∑ a v + ∑ bv + v ∈S av is equivalent to minimizing v ∈T {v . w) ∈ E. No source or sink. w) ∈ E.

t) with capacity -pv if pv < 0. s Include an arc from v to w if can’t do v without also doing w. Assign infinite capacity to all prerequisite arcs. w. T) is min cut if and only if S \ {s} is optimal set of projects. Add arc (s. Can’t remove block v before w or x. (S. s s s s s w w u w -pw s v x v x y z t pv v Feasible Infeasible 77 ∞ ∞ -px x 78 Project Selection Claim. s Project Selection Open-pit mining (studied since early 1960’s). T ) = = ∑pv v ∈T : pv > 0 v : pv > 0 + v ∈S : pv < 0 ∑ (− p v ) s ∑pv − ∑pv v ∈S s constant w u pu -pw s w v t y z x py pv v ∞ ∞ -px x 79 80 .processing cost. For notational convenience. {v.Project Selection Prerequisite graph. s cap (S . x} is infeasible subset of projects. s Project Selection Project selection formulation. define ps = pt = 0. Add arc (v. s Infinite capacity arcs ensure S \ {s} is feasible. x} is feasible subset of projects. Max revenue because: Blocks of earth are extracted from surface to retrieve ore. Each block v has net value pv = value of ore . {v. v) with capacity pv if pv > 0.