Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 473Lecture ?1 CS473-Algorithms I Lecture ? Network Flows Flow Networks & Flows.

Similar presentations


Presentation on theme: "CS 473Lecture ?1 CS473-Algorithms I Lecture ? Network Flows Flow Networks & Flows."— Presentation transcript:

1 CS 473Lecture ?1 CS473-Algorithms I Lecture ? Network Flows Flow Networks & Flows

2 CS 473Lecture ?2 FLOW NETWORKS & FLOWS A flow network: a directed graph G = ( V, E ) –Two distinguished vertices : a source s and a sink t –Each edge has a nonegative capacity c(u,v)  0 (if (u,v)  E then c(u,v) = 0) –for convenience :  v  V – { s,t }, s v t, i.e., every vertex v lies on some path from s to t.

3 CS 473Lecture ?3 A positive flow p on G: a fn p:VxV  R  0 satisfying –capacity constraint: 0  p(u,v)  c(u,v),  u,v  V i.e., flow from one vertex to another cannot exceed the capacity note : p(u,v) > 0  (u,v)  E with c(u,v) > 0 –flow conservation: Kirschoff’s current law total positive flow leaving a vertex = total positive flow entering the vertex  u  V- { s,t } FLOW NETWORKS & FLOWS

4 CS 473Lecture ?4 FLOW NETWORKS & FLOWS value of a positive flow: a sample flow network G and a positive flow p on G: p/c for every edge s v1v1 v3v3 v2v2 v4v4 t 2/2 1/3 2/3 0/1 1/2 2/3 1/3 2/3 note: flow  capacity at every edge note: flow conservation holds at every vertex (except s and t) 1/1

5 CS 473Lecture ?5 FLOW NETWORKS & FLOWS s v1v1 v3v3 v2v2 v4v4 t 2/2 1/3 2/3 0/1 1/2 2/3 1/3 2/3 1/1

6 CS 473Lecture ?6 FLOW NETWORKS & FLOWS cancellation : can say positive flow either goes from u to v or from v to u, but not both –if not true, can transform by cancellation to be true –e.g.,  3 units of net positive flow from u to v –  can be obtained by canceling 2 units of flow in each direction capacity constraint still satisfied : flows only decrease flow conservation still satisfied : flow-in & flow-out both reduced by the same amount vu 5/6 2/4 vu 3/6 0/4

7 CS 473Lecture ?7 NET FLOW VERSUS POSITIVE FLOW DEFINITIONS positive flow is more intuitive net flow brings mathematical simplification: half as many summations to write A net flow f on G: a fn f:VxV  R satisfying –capacity constraint:  u,v  V f(u,v)  c(u,v) –skew symmetry:  u,v  V f(u,v)= - f(v,u) thus, f(u,u)= - f(u,u)  f(u,u)=0  net flow from a vertex to itself is 0 –flow conservation:  u  V- {s,t}, total net flow into a vertex is 0 Nonzero net flow from u to v  (u,v)  E, or (v,u)  E, or both. value of a net flow : |f|= net flow out of the source

8 CS 473Lecture ?8 NET FLOW VERSUS POSITIVE FLOW DEFINITIONS equivalence of net flow and positive flow definitions: define net flow in terms of positive flow: –f(u,v)= p(u,v) - p(v,u) Given definition of p, this def. of f satisfies (1) capacity constraint, (2) skew symmetry, and (3) flow constraint.

9 CS 473Lecture ?9 NET FLOW VERSUS POSITIVE FLOW DEFINITIONS define positive flow in terms of net flow: f(u,v), if f(u,v) > 0 0, if f(u,v)  0 Given definition of f, this def. of p satisfies (1) capacity constraint, (2) flow constraint. p(u,v)=

10 CS 473Lecture ?10 NET FLOW VERSUS POSITIVE FLOW DEFINITIONS proof of (2)  flow conservation in net flow model means that –  positive net flow leaving a vertex = positive net flow entering the vertex split summation because of skew symmetry

11 CS 473Lecture ?11 FLOW NETWORKS & MAXIMUM FLOW PROBLEM maximum flow problem : given a flow network G with source s and sink t –find a flow of maximum value from s to t flow network with multiple sources and sinks : –a flow network G with m sources {s 1, s 2,..., s m }= S m and n sinks {t 1, t 2,..., t n }= T n –Max flow problem : find a flow of max value from m sources to n sinks –Can reduce to an ordinary max-flow problem witha single source & a single sink

12 CS 473Lecture ?12 FLOW NETWORKS & MAXIMUM FLOW PROBLEM add a supersource s and a supersink t such that –Add a directed edge (s,s i ) with capacity c(s,s i )=  for i=1,2,...,m –Add a directed edge (t,t i ) with capacity c(t,t i )=  for i=1,2,...,n –i.e., V = V  {s,t}; E = E  {(s,s i ) with c(s,s i )=  :  s i }  {(t,t i ) with c(t,t i )=  :  t i }

13 CS 473Lecture ?13 s1s1 10 FLOW NETWORKS & MAXIMUM FLOW PROBLEM s2s2 s3s3 s4s4 v1v1 v1v1 v1v1 t1t1 t1t1 Example: A flow network with multiple sources and sinks 6 4 7 5 3 14 6 4 7 s1s1 10 s1s1 s1s1 s1s1 v1v1 v1v1 v1v1 t1t1 t1t1 6 4 7 5 3 14 6 4 7 t s      

14 CS 473Lecture ?14 NET FLOW VERSUS POSITIVE FLOW DEFINITIONS Claim : any flow in a multiple-source multiple-sink flow network G = (v, t) –Corresponds to a flow of identical value in G = ( v, t ) Proof : define f for G interms of G

15 CS 473Lecture ?15 IMPLICIT SUMMATION NOTATION where X,Y  V functions over sets imply summation; because will write lots of summations. Example: value of a flow f = Example: flow conservation :

16 CS 473Lecture ?16 IMPLICIT SUMMATION NOTATION L1 : let G=(V,E) be a flow network, and let f be a flow on G, then: (a) For X  V; f(X,X) = 0 –Because each f(u,v) canceled by f(v,u)= – f(u,v) due to skew symmetry. (b) for X,Y  V; f(X,Y) = – f(Y,X) –Generalization of f(X,X)=0, same reasoning (c) for X,Y,Z  V, with X  Y=  –f(X  Y,Z) = f(X,Z)+f(Y,Z) & f(Z,X  Y) = f(Z,X)+f(Z,Y) –Split summation into sum of two summations, one over X, one over Y

17 CS 473Lecture ?17 IMPLICIT SUMMATION NOTATION XX Y f(x,y) f(X,X) = 0 f(y,x) X Y Z f(x,z) f(y,z) XYXY f(X,Y) = – f(Y,X) f(X  Y,Z) = f(X,Z) + f(Y,Z)

18 CS 473Lecture ?18 IMPLICIT SUMMATION NOTATION (d) For any X  V – {s,t}; f(X,V) = 0  f(V,X) = – f(X,V) = 0 due to flow conservation L2: |f| = f(V,t)

19 CS 473Lecture ?19 CUTS OF FLOW NETWORKS & UPPER BOUND ON MAX FLOW def: A cut (S, T) of a flow network is a partition of V into S and T = V-S such that s  S and t  T –Similar to the cut definition given for MST –Differences: G is a directed graph here & we insist that s  S and t  T def: f(S, T) is the net flow across the cut (S, T) of G for a flow f on G –Add all edges S  T and negative of all edges T  S due to skew symmetry def: c(S, T) is the capacity across the cut (S, T) of G –not like flow because no skew symmetry; just add edges S  T (no neg. values)

20 CS 473Lecture ?20 (S 1, T 1 ) = ({s, a, b}, {c, d, t}) f(S 1, T 1 ) = f(a, c) + f(b, c) + f(b, d) = 12 + (-4) + 11 = 19 c(S 1, T 1 ) = c(a, c) + c(b, d) = 12 + 14 = 26 (S 2, T 2 ) = ({s, a}, {b, c, d, t}) f(S 2, T 2 ) = f(s, b) + f(a, b) + f(a, c) = 8 + (-1) + 12 = 19 c(S 2, T 2 ) = c(s, b) + c(a, b) + c(a, c) = 13 + 10 + 12 = 35 ac 15/20 11/16 11/14 12/12 bd s t 4/4 4/9 8/13 T1T1 Example: 0/10 1/4 7/7 S1S1 T1T1 S2S2 T2T2 CUTS OF FLOW NETWORKS & UPPER BOUND ON MAX FLOW

21 CS 473Lecture ?21 WHY WE NEED NEGATIVE FLOWS Reasons behind negative flow across a cut : S f(S,T) = f(a,c) – f(c,b) + f(b,d) = 5 – 0 + 5 = 10 = |f| no neg. Flow across the cut ac ?/5 ?/10 bd s t ?/5 T S a c 5/5 5/10 bd s t 0/5 5/5 T

22 CS 473Lecture ?22 WHY WE NEED NEGATIVE FLOWS Exploit capacity c(c,b) = 5 to induce negative flow across (S,T) –i.e., sacrifice negative flow of 5 for a better utilization of c(a,c) = 10 & c(b,d) = 10 S ac 5/5 10/10 bd s t 5/5 T f '(S,T) = f(a,c) – f(c,b) + f(b,d) = (5+5) – (5) + (5+5) = 10 – 5 – 10 = 15 = | f |

23 CS 473Lecture ?23 CUTS OF FLOW NETWORKS & UPPER BOUND ON MAX FLOW L3: For any flow f on G, the net flow across any cut (S, T) of G = |f| –f(S, T) = f(S, V-S) = f(S, V) – f(S, S) by L1(c) = f(S, V) + 0 = f(S, V)by L1(a) = f(s  (S – s), V) = f(s, V) + f(S – s, V) by L1(c) = f(s, V) + 0 = f(s, V) = |f| by L1(d) since S-s  V – {s, t}

24 CS 473Lecture ?24 CUTS OF FLOW NETWORKS & UPPER BOUND ON MAX FLOW C1: the value of any flow f in G is bounded above by the capacity of any cut of G –Let (S, T) be any cut of G –|f| = f(S, T) =

25 CS 473Lecture ?25 RESIDUAL NETWORKS intuitively: the residual network G f of a flow network G with a flow f –Consists of edges that can admit more flow def: given a flow network G = (V, E) with a flow f –residual capacity of (u, v): c f (u, v) = c(u, v) – f(u, v) c f (u, v): additional flow we can push from u to v without exceeding c(u, v) –residual network of G induced by f is the graph G f = (V, E f ) with Strictly positive residual capacities: E f = {(u, v)  V x V: c f (u, v) > 0}

26 CS 473Lecture ?26 RESIDUAL NETWORKS recall: if both (u, v)  E and (v, u)  E then –Transform such that either f(u, v) = 0 or f(v, u) = 0 by cancellation examples: (1) both (u, v)  E and (v, u)  E c f (u, v) = c (u, v) – f (u, v) = 5 – 3 = 2 > 0 c f (v, u) = c (v, u) – f (v, u) = 1 – (–3) = 4 > 0 uv 3/5 0/1 uv 2 4

27 CS 473Lecture ?27 RESIDUAL NETWORKS (2) (u, v)  E but (v, u)  E and f(u, v) ≥ 0: (v, u) becomes an edge of E f |E f | ≤ 2|E|, since (u,v)  E f only if at least one of (u,v) and (v,u) is in E note: c f (u, v) + c f (v, u) = c(u, v) + c(v, u) uv 5/5 uv 5 c f (u, v) = 5 – 5 = 0 ≤ 0 × c f (v, u) = 0 – (– 5) = 5 > 0 √ uv 3/5 uv 2 3 c f (u, v) = 5 – 3 = 2 > 0 √ c f (v, u) = 0 – (– 3) = 3 > 0 √

28 CS 473Lecture ?28 FLOW SUMS def: let f 1 and f 2 be flows on G flow sum f 1 +f 2 : VxV  R  ( f 1 +f 2 )(u,v) = f 1 (u,v)+f 2 (u,v) L4: flow sum f 1 + f 2 satisfies (2) skew symmetry & (3) flow conservation –(2) ( f 1 + f 2 )(u, v) = f 1 (u, v) + f 2 (u, v) = – f 1 (v, u) – f 2 (v, u) = – (f 1 (v, u) + f 2 (v, u)) = – ( f 1 + f 2 )(u, v) –(3) note: flow sum may violate (1) capacity constraint –f 1 (u,v), f 2 (u,v) ≤ c(u,v) may not mean that f 1 (u,v)+f 2 (u,v) ≤ c(u,v)

29 CS 473Lecture ?29 FLOW SUMS How a flow on G f relates to a flow on the original network G? L5: let f be a flow on G and let f ' be a flow on G f then, flow sum f+f ' is a flow on G with value | f+f '| = | f |+| f '| –First verify that f+f ' is a flow on G ie, show that f+f ' satisfies (1) capacity constraint, (2) skew symmetry, (3) flow constraint note that f ' is also a flow on G –so, by L4, f+f ' already satisfies (2) and (3) on G thus it remains to show that f+f ' satisfies (1) on G –(f+f ')(u, v) = f(u, v)+f '(u, v) ≤ f(u, v)+c f (u, v) = f(u, v)+(c(u, v) – f(u, v)) = c(u, v)

30 CS 473Lecture ?30 FLOW SUMS Second show that | f + f '| = | f |+| f '| –|f+f '| = = = | f |+| f '|

31 CS 473Lecture ?31 AUGMENTING PATHS For a flow f on G –augmenting path p is a simple path from s to t in G f c f (p): residual capacity of a path p = –i.e., c f (p) = max. amount of the flow we can ship along edges of p on G f

32 CS 473Lecture ?32 AUGMENTING PATHS L6: let f be a flow on G, and let p be an augmenting path in G f. Let f p be a flow on G f with value | f p | = c f (p) > 0 defined as c f (p) if (u,v)  p in G f f p (u,v) = 0 otherwise then, f’ = f+f p is a flow on G with value | f’ | = | f | + | f p | > | f |

33 CS 473Lecture ?33 AUGMENTING PATHS example: a single path p on G –can easily say that it is not all of G since flow is not conserved on p –define flow f p on G f with c f (p) = min{2, 4, 5, 2, 2, 2} = 2 st 3/52/65/52/32/4 p on G with f: st 2 3 4 2 5 2 1 2 2 p on G f : st 2/22/4 2/5 2/2 f p on G f :

34 CS 473Lecture ?34 AUGMENTING PATHS example (cont.): a single path p on G –flow on p in G that results from augmenting along path p: st 3/52/65/52/32/4 p on G with f: st 5/54/63/50/34/4 f + f p on p of G: +2 -2 +2 st 2/22/4 2/5 2/2 f p on G f :

35 CS 473Lecture ?35 MAX-FLOW MIN-CUT THEOREM Thm (max-flow min-cut): the following are equivalent for a flow f on G –(1) f is a maximum flow –(2) G f contains no augmenting paths –(3) | f | = c(S, T) for some cut (S, T) of G

36 CS 473Lecture ?36 MAX-FLOW MIN-CUT THEOREM proof (1)  (2): f is a max flow on G –for contradiction, assume that G contains an augmenting path p with c f (p) > 0 –then, by L6 flow sum f + f p is a flow on G f with value > | f |, contradiction

37 CS 473Lecture ?37 MAX-FLOW MIN-CUT THEOREM proof (2)  (3): G f contains no augmenting path, i.e., G f contains no path from s to t –define S = s  {u:  a path from s to u in G f } –define T = V – S –(S, T) is a cut: s  S & t  S  t  T because  no path from s to t in G f

38 CS 473Lecture ?38 MAX-FLOW MIN-CUT THEOREM proof (2)  (3) (cont.): –for each u  S and v  T, we have f(u, v) = c(u, v) Otherwise c f (u,v) = c(u,v) – f(u,v) > 0  v  S, contradiction uv uv s SV-S u v …. so, by L3, | f | = f(S, T) =c(S,T)

39 CS 473Lecture ?39 MAX-FLOW MIN-CUT THEOREM proof (3)  (1): | f | = c(S,T) for some cut (S,T) of G –already proved by C1 that | f | ≤ c(S, T) for all cuts (S, T) –so, | f | = c(S, T) implies that f is a max flow


Download ppt "CS 473Lecture ?1 CS473-Algorithms I Lecture ? Network Flows Flow Networks & Flows."

Similar presentations


Ads by Google