Chapter 7 Network Flow CS 3: Winter 1 1
Soviet Rail Network, Reference: On the hitory of the tranportation and maximum flow problem. Alexander Schrijver in Math Programming, 1: 3,.
Maximum Flow and Minimum Cut Max flow and min cut. Two very rich algorithmic problem. Cornertone problem in combinatorial optimization. Beautiful mathematical duality. Nontrivial application / reduction. Data mining. Open-pit mining. Project election. Airline cheduling. Bipartite matching. Baeball elimination. Image egmentation. Network connectivity. Network reliability. Ditributed computing. Egalitarian table matching. Security of tatitical data. Network intruion detection. Multi-camera cene recontruction. Many many more 3
Minimum Cut Problem Flow network. Abtraction for material flowing through the edge. G = (V, E) = directed graph, no parallel edge. Two ditinguihed node: = ource, t = ink. c(e) = capacity of edge e. ource 3 t ink capacity 3 7
Cut Def. An -t cut i a partition (A, B) of V with A and t B. Def. The capacity of a cut (A, B) i: cap(a, B) c(e) e out of A 3 t A 3 7 Capacity = + + = 3
Cut Def. An -t cut i a partition (A, B) of V with A and t B. Def. The capacity of a cut (A, B) i: cap(a, B) c(e) e out of A 3 t A 3 7 Capacity = + + + 3 =
Minimum Cut Problem Min -t cut problem. Find an -t cut of minimum capacity. 3 t A 3 7 Capacity = + + = 7
Flow Def. An -t flow i a function that atifie: For each e E: For each v V {, t}: f (e) c(e) f (e) f (e) e in to v e out of v [capacity] [conervation] Def. The value of a flow f i: v( f ) f (e). e out of 3 t capacity flow 3 7 Value =
Flow Def. An -t flow i a function that atifie: For each e E: For each v V {, t}: f (e) c(e) f (e) f (e) e in to v e out of v [capacity] [conervation] Def. The value of a flow f i: v( f ) f (e). e out of 3 3 t capacity 1 flow 11 11 3 7 Value =
Maximum Flow Problem Max flow problem. Find -t flow of maximum value. 1 3 t capacity flow 1 1 3 7 Value =
Flow and Cut Flow value lemma. Let f be any flow, and let (A, B) be any -t cut. Then, the net flow ent acro the cut i equal to the amount leaving. f (e) f (e) v( f ) e out of A e in to A 3 3 t A 1 11 11 3 7 Value = 11
Flow and Cut Flow value lemma. Let f be any flow, and let (A, B) be any -t cut. Then, the net flow ent acro the cut i equal to the amount leaving. f (e) f (e) v( f ) e out of A e in to A 3 3 t A 1 11 11 3 7 Value = + + - 1 + 11 = 1
Flow and Cut Flow value lemma. Let f be any flow, and let (A, B) be any -t cut. Then, the net flow ent acro the cut i equal to the amount leaving. f (e) f (e) v( f ) e out of A e in to A 3 3 t A 1 11 11 3 7 Value = - + - + = 13
Flow and Cut Flow value lemma. Let f be any flow, and let (A, B) be any -t cut. Then f (e) f (e) v( f ). e out of A e in to A Pf. by flow conervation, all term except v = are v( f ) f (e) e out of v A (by definition) f (e) f (e) e out of v e in to v f (e) f (e). e out of A e in to A 1
Flow and Cut Weak duality. Let f be any flow, and let (A, B) be any -t cut. Then the value of the flow i at mot the capacity of the cut. Cut capacity = 3 Flow value 3 3 t A 3 7 Capacity = 3
Flow and Cut Weak duality. Let f be any flow. Then, for any -t cut (A, B) we have v(f) cap(a, B). Pf. v( f ) f (e) f (e) e out of A e in to A f (e) e out of A c(e) e out of A cap(a, B) A 7 B t 1
Certificate of Optimality Corollary. Let f be any flow, and let (A, B) be any cut. If v(f) = cap(a, B), then f i a max flow and (A, B) i a min cut. Value of flow = Cut capacity = Flow value 1 3 t A 1 1 3 7 17
Toward a Max Flow Algorithm Greedy algorithm. Start with f(e) = for all edge e E. Find an -t path P where each edge ha f(e) < c(e). Augment flow along path P. Repeat until you get tuck. 1 3 t Flow value = 1
Toward a Max Flow Algorithm Greedy algorithm. Start with f(e) = for all edge e E. Find an -t path P where each edge ha f(e) < c(e). Augment flow along path P. Repeat until you get tuck. 1 X 3 X t X Flow value = 1
Toward a Max Flow Algorithm Greedy algorithm. Start with f(e) = for all edge e E. Find an -t path P where each edge ha f(e) < c(e). Augment flow along path P. Repeat until you get tuck. locally optimality global optimality 1 1 3 t 3 t greedy = opt = 3
Reidual Graph Original edge: e = (u, v) E. Flow f(e), capacity c(e). u 17 capacity v flow Reidual edge. "Undo" flow ent. e = (u, v) and e R = (v, u). Reidual capacity: u 11 reidual capacity v c(e) f (e) c f (e) if f (e) e E if e R E reidual capacity Reidual graph: G f = (V, E f ). Reidual edge with poitive reidual capacity. E f = {e : f(e) < c(e)} {e R : f(e) > }. 1
7. Ford-Fulkeron Demo
Ford-Fulkeron Algorithm G: capacity 3 t 3
Ford-Fulkeron Algorithm G: flow capacity 3 t Flow value =
Ford-Fulkeron Algorithm G: X X flow capacity X 3 t Flow value = G f : reidual capacity 3 t
Ford-Fulkeron Algorithm G: X X X X 3 t Flow value = G f : 3 t
Ford-Fulkeron Algorithm G: X X X X 3 t Flow value = G f : 3 7 t 7
Ford-Fulkeron Algorithm G: X X X X 3 t Flow value = 1 G f : 3 1 t
Ford-Fulkeron Algorithm X 3 G: X 7 X X X 3 t Flow value = 1 G f : 3 1 t
Ford-Fulkeron Algorithm 3 G: 7 3 t Flow value = 1 3 1 G f : 7 1 1 1 3 t 3
Ford-Fulkeron Algorithm 3 G: 7 3 t Cut capacity = 1 Flow value = 1 3 1 G f : 7 1 1 1 3 t 31
Augmenting Path Algorithm Augment(f, c, P) { b bottleneck(p) foreach e P { } if (e E) f(e) f(e) + b ele f(e R ) f(e R ) - b } return f forward edge revere edge Ford-Fulkeron(G,, t, c) { foreach e E f(e) G f reidual graph } while (there exit augmenting path P) { f Augment(f, c, P) update G f } return f 3
Max-Flow Min-Cut Theorem Augmenting path theorem. Flow f i a max flow iff there are no augmenting path. Max-flow min-cut theorem. [Elia-Feintein-Shannon, Ford-Fulkeron ] The value of the max flow i equal to the value of the min cut. Pf. We prove both imultaneouly by howing TFAE (the following are equivalent): (i) There exit a cut (A, B) uch that v(f) = cap(a, B). (ii) Flow f i a max flow. (iii) There i no augmenting path relative to f. (i) (ii) Thi wa the corollary to weak duality lemma. (ii) (iii) We how contrapoitive. Let f be a flow. If there exit an augmenting path, then we can improve f by ending flow along path. 33
Proof of Max-Flow Min-Cut Theorem (iii) (i) Let f be a flow with no augmenting path. Let A be et of vertice reachable from in reidual graph. By definition of A, A. By definition of f, t A. v( f ) f (e) f (e) e out of A e in to A c(e) e out of A cap(a, B) A B t original network 3
Running Time Aumption. All capacitie are integer between 1 and C. Invariant. Every flow value f(e) and every reidual capacity c f (e) remain an integer throughout the algorithm. Theorem. The algorithm terminate in at mot v(f*) nc iteration. Pf. Each augmentation increae value by at leat 1. Corollary. If C = 1, Ford-Fulkeron run in O(mn) time. Integrality theorem. If all capacitie are integer, then there exit a max flow f for which every flow value f(e) i an integer. Pf. Since algorithm terminate, theorem follow from invariant. 3
Kleinberg HW 7.3 The figure how a flow network on which an -t flow ha been computed. The capacity of each edge appear a a label next to the edge, and the number in the boxe give the amount of flow ent on each edge (Edge without boxed number have no flow being ent on them). What i the value of thi flow? I thi a maximum (,t) flow in thi graph? 3
Kleinberg HW 7.3 The figure how a flow network on which an -t flow ha been computed. The capacity of each edge appear a a label next to the edge, and the number in the boxe give the amount of flow ent on each edge (Edge without boxed number have no flow being ent on them). What i the value of thi flow? I thi a maximum (,t) flow in thi graph? No. 37
Kleinberg HW 7.3 The figure how a flow network on which an -t flow ha been computed. The capacity of each edge appear a a label next to the edge, and the number in the boxe give the amount of flow ent on each edge (Edge without boxed number have no flow being ent on them). (b) Find a minimum -t cut in the flow network pictured, and alo ay what it capacity i. 3
Kleinberg HW 7.3 The figure how a flow network on which an -t flow ha been computed. The capacity of each edge appear a a label next to the edge, and the number in the boxe give the amount of flow ent on each edge (Edge without boxed number have no flow being ent on them). (b) Find a minimum -t cut in the flow network pictured, and alo ay what it capacity i. Min cut i: ({,a,b,c},{d,t}); the capacity i 11. 3
Kleinberg HW 7. Decide whether you think the following tate i true or fale. If it i true, give a hort explanation. If it i fale give a counter-example. Let G be an arbitrary flow network, with a ource, a ink t, and a poitive integer capacity c e on every edge; and let (A,B) be a minimum -t cut with repect to thee capacitie. Now uppoe we add 1 to every capacity; then (A,B) i till a minimum -t cut with repect to thee new capacitie.
Kleinberg HW 7. Decide whether you think the following tate i true or fale. If it i true, give a hort explanation. If it i fale give a counter-example. Let G be an arbitrary flow network, with a ource, a ink t, and a poitive integer capacity c e on every edge; and let (A,B) be a minimum -t cut with repect to thee capacitie. Now uppoe we add 1 to every capacity; then (A,B) i till a minimum -t cut with repect to thee new capacitie. Anwer: Fale. Conider a graph with node,v,w,t, and edge: (,v), (v,w), (w,t), capacitie of on (,v) and (w,t) and a capacity of 1 on (v,w). The maximum flow ha value 1, and doe not aturate the edge out of. 1
Kleinberg HW 7.7 Conider a et of mobile computing client in a certain town who each need to be connected to one of everal poible bae tation. We ll uppoe there are n client, with the poition of each client pecified by it (x,y) coordinate in the plane. There are alo k bae tation; the poition of each of thee i pecified by (x,y) coordinate a well. For each client, we wih to connect it to exactly one of the bae tation. Our choice of connection i contrained in the following way. There i a range parameter r: a client can only be connected to a bae tation that i within ditance r. There i alo a load parameter L: no more than L client can be connected to any ingle bae tation. Your goal i to deign a polynomial-time algorithm for the following problem. Give the poition of a et of bae tation, be connected imultaneouly to a bae tation, ubject to the range and load condition in the previou paragraph.
Kleinberg HW 7.7 There i a range parameter r: a client can only be connected to a bae tation that i within ditance r. There i alo a load parameter L: no more than L client can be connected to any ingle bae tation. Your goal i to deign a polynomial-time algorithm for the following problem. Give the poition of a et of bae tation, be connected imultaneouly to a bae tation, ubject to the range and load condition in the previou paragraph. 3
Kleinberg HW 7.7 There i a range parameter r: a client can only be connected to a bae tation that i within ditance r. There i alo a load parameter L: no more than L client can be connected to any ingle bae tation. Your goal i to deign a polynomial-time algorithm for the following problem. Give the poition of a et of bae tation, be connected imultaneouly to a bae tation, ubject to the range and load condition in the previou paragraph. Anwer: (getting tarted) Build the flow network a node v i for each client, a node w j for each bae and an edge (v i,w j ) of capacity 1 if client i i in range of bae tation j. Latly, expand thi graph by adding the ource node that connect to each of the client node with capacity 1, and we connect each of the bae tation to a ink node t by an edge of capacity L. Now how that there i a feaible way to connect all client to bae tation if and only if there i an -t flow of value n. Running time i time required to olve max-flow on graph with O(n+k) node and O(nk) edge