Today Flow review Augmenting path Ford-Fulkeron Algorithm Intro to cut (reaon: prove correctne)
Flow Network = ource, t = ink. c(e) = capacity of edge e Capacity condition: f(e) c(e) Conervation condition: for v V {, t}: " f(e) = f(e) e into v e out of v flow = ource 7 t ink
Flow The value of a flow f i: v(f) = f(e) e out of value = flow = ource 7 t ink
Flow The value of a flow f i: v(f) = f(e) e out of value = flow = ource 7 t ink
Maximum Flow Problem Find -t flow of maximum value. value = flow = ource 7 t ink
Toward a Max-Flow Algorithm Key idea: repeatedly chooe path and augment the amount of flow on thoe path a much a poible until capacitie are met
Toward a Max Flow Algorithm Problem: poible to get tuck at a flow that i not maximum, no more path with exce capacity t Flow value =
Reidual Graph Original edge: e = (u, v) E. Flow f(e), capacity c(e). u 7 v Create two reidual edge Forward edge e = (u, v) with capacity c(e) - f(e) Backward/revere edge e = (v, u) with capacity f(e) u reidual capacity v Reidual graph: G f = (V, E f ). E f = edge with poitive reidual capacity E f = {e : f(e) < c(e)} {e : f(e) > }
Augmenting Path Definition: an -t path P in G f i an augmenting path Idea: ue an augmenting path to augment flow in G Increae flow on forward edge Decreae flow on backward edge Definition: let bottleneck(p, f) be the minimum reidual capacity (i.e., capacity in G f ) of any edge in P Example on board
Augmenting Path Ue path P in G f to to update flow f Augment(f, P) { b = bottleneck(p, f) // edge on P with leat reidual capacity foreach e = (u,v) P { if e i a forward edge f(e) = f(e) + b // forward edge: increae flow ele let e = (v, u) f(e ) = f(e ) - b // backward edge: decreae flow } return f }
Augmenting Path Claim: Let f be a flow and let f = Augment(f, P). Then f i a flow. Proof idea: verify capacity and conervation condition ) Capacity: by deign of reidual graph ) Conervation: check that net change at each node i zero Proof ketch on board
Ford-Fulkeron Algorithm Repeat: find an augmenting path, and augment! Ford-Fulkeron(G,, t) { foreach e E f(e) = // initially, no flow G f = copy of G // reidual graph = original graph } while (there exit an -t path P in G f ) { f = Augment(f, P) // change the flow update G f // build a new reidual graph } return f
Example G: t Flow value =
Example G t G f Flow value = t
Example G t G f Flow value = t
Example G t G f Flow value = 7 t
Example G t Gf Flow value = t
Example G 7 t G f Flow value = t
Example G 7 t max flow = G f 7 t
Termination Aumption. All capacitie are poitive integer. Invariant. Every flow value f(e) and every reidual capacity c f (e) remain an integer throughout the algorithm. Theorem. Let OPT = value of max flow. The algorithm terminate in at mot OPT iteration, with OPT C, the total capacity of the edge leaving the ource. Proof?
Running Time? There are at mot C augment operation. How long doe it take for each? Find a reidual path Compute bottleneck capacity Update flow Update reidual graph O(m+n) O(m) O(m) O(m) Total running time: O(C(m+n))
Cut An -t cut i a partition (A, B) of V with A and t B. The capacity of a cut (A, B) i c(a,b) = Σ c(e) e out of A A B ource t ink capacity of cut = 7
Cut capacity of cut = + + + = (Capacity i um of weight on edge leaving A.) A B ource t ink 7
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. value = A ource f(e) - f(e) = v(f) e out of a e into a 7 t ink B
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. value = ource f(e) - f(e) = v(f) e out of a e into a A 7 B t ink
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. value = A ource f(e) - f(e) = v(f) e out of a e into a 7 t ink B
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). Proof: e out of A e into A v(f) = f(e) e out of = ( f(e) - f(e) ) v A e out of v = f(e) - f(e) e out of A e into A e into v by definition by flow conervation, all term except v = are if both endpoint of e are in A, there will be canceling term for that edge
Max-Flow Min-Cut There i a deep connection between flow and cut in network Next time, we will prove that Ford-Fulkeron i correct by proving the Max-Flow Min-Cut Theorem