flow networks flow maximum flow
play

Flow networks, flow, maximum flow Can interpret directed graph as - PowerPoint PPT Presentation

Flow networks, flow, maximum flow Can interpret directed graph as flow network. Material courses through some system from some source to some sink. Source produces material at some steady rate, sink consumes at same rate. Examples:


  1. Flow networks, flow, maximum flow Can interpret directed graph as “flow network”. Material courses through some system from some source to some sink. Source produces material at some steady rate, sink consumes at same rate. Examples: • water through system of pipes • current through electrical network • data through network • trucks from factory to warehouse Each edge has given capacity (pipe: x gallons of water per minute; street: y trucks per hour; network: z kB per second). Vertices are “junctions”, for those other than source and sink, material flows through them without collecting in them (i.e., rate at which material enters vertex equals rate at which it leaves it; “flow conservation”). In maximum-flow problem , we wish to compute greatest possible rate of trans- portation from source to sink. Maximum Flow 1

  2. Some definitions Flow network G = ( V, E ) is directed graph, each edge ( u, v ) ∈ E has non-negative capacity c ( u, v ) ≥ 0 . If ( u, v ) �∈ E , we assume c ( u, v ) = 0 . Two distinguished vertices: source s and sink t . We assume that every vertex lies on some path from s to t , i.e., for each v ∈ V , there is a path s ❀ v ❀ t (implies that G is connected, | E | ≥ | V | − 1 ). A flow in G is a real-valued function f : V × V → I R, that satisfies these three properties: Capacity constraint: For all u, v ∈ V , we require f ( u, v ) ≤ c ( u, v ) . Flow from one vertex to another must not exceed given capacity. Skew symmetry: For all u, v ∈ V , we require f ( u, v ) = − f ( v, u ) . Flow from vertex u to vertex v is negative of flow in reverse direction. Flow conservation: For all u ∈ V − { s, t } , we require � f ( u, v ) = 0 . v ∈ V Total flow out of a vertex (other than source or sink) is 0 . Can rewrite as ∀ v ∈ V − { s, t } : � u ∈ V f ( u, v ) = 0 , i.e., total flow into a vertex is 0 . Maximum Flow 2

  3. f ( u, v ) — can be positive, zero, or negative — is called flow from u to v . The value of flow f is defined as the total flow leaving the source (and thus entering the sink): � | f | = f ( s, v ) v ∈ V Note: | · | does not mean “absolute value” or “cardinality”). The total positive flow entering vertex v is � f ( u, v ) u ∈ V : f ( u,v ) > 0 Also, total positive flow leaving vertex u is � f ( u, v ) v ∈ V : f ( u,v ) > 0 The total net flow at a vertex v is total positive flow leaving v − total positive flow entering v Maximum Flow 3

  4. Edmonton Saskatoon 12 20 16 Vancouver Winnipeg 10 4 9 7 13 4 14 Calgary Regina 12/12 a c 15/20 11/16 s 10 1/4 4/9 7/7 t 8/13 4/4 b d 11/14 Second figure shows flow f in G with value | f | = 19 . Maximum Flow 4

  5. Cancellation Suppose a company ships 8 crates per day from Edmonton to Calgary, and 3 crates per day from Calgary to Edmonton. Natural enough, but we can’t represent these shipments directly by flows: skey- symmetry is violated [must have f ( u, v ) = − f ( v, u ) ]. However, the strategy is pointless anyway: why ship 8 crates from Edmonton to Calgary, and 3 creates back, instead of just shipping 5 crates from Edmonton to Calgary? In effect, 3 of the 8 crates from Edmonton to Calgary are cancelled by the 3 crates from Calgary to Edmonton. We represent this with a flow: we have f ( E, C ) = 5 and f ( C, E ) = − 5 . Maximum Flow 5

  6. In general, cancellation allows to represent shipments between two cities by a flow that is positive along at most one of the two edges . Cancellation will arise implicitly in the algorithms. • Suppose ( u, v ) has flow of f ( u, v ) . • We may increase flow on edge ( v, u ) by some amount d . • Mathematically, this must decrease f ( u, v ) by d . • We think of these d units as cancelling d units that are already on ( u, v ) (increase in one direction cancels flow in other). Maximum Flow 6

  7. Technical tools Implicit summation. Let X, Y ⊆ V . Then � � f ( X, Y ) = f ( x, y ) x ∈ X y ∈ Y For example, flow-conservation � ∀ u ∈ V − { s, t } f ( u, v ) = 0 v ∈ V can be written simply as f ( u, V ) = 0 ∀ u ∈ V − { s, t } Commonly occuring identities 1. For all X ⊆ V , we have f ( X, X ) = 0 Because each f ( u, v ) cancels f ( v, u ) , which = − f ( u, v ) by skew symmetry. 2. For all X, Y ⊆ V , we have f ( X, Y ) = − f ( Y, X ) Generalisation of f ( X, X ) = 0 , same reasoning. 3. For all X, Y, Z ⊆ V with X ∩ Y = ∅ , we have 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 . Maximum Flow 7

  8. The Ford-Fulkerson method Three important ideas: 1. residual networks 2. augmenting paths 3. cuts Method is iterative: 1. Start with f ( u, v ) = 0 for all u, v ∈ V 2. At each iteration, increase flow value by finding “augmenting path” — a path from source to sink along which we can increase flow — and then augment flow along this path. 3. Repeat until no augmenting path can be found. Pseudocode: 1: initialise flow f to 0 2: while there exists an augmenting path p do 3: augment flow f along p 4: end while Maximum Flow 8

  9. Residual networks Idea: Residual network consists of edges that can admit more flow. Formally: Consider vertices u and v . Amount of additional flow we can push from u to v before exceeding capacity c ( u, v ) is residual capacity of ( u, v ) : c f ( u, v ) = c ( u, v ) − f ( u, v ) . Note: When flow is negative, then residual capacity c f ( u, v ) is greater than c ( u, v ) . Interpretation: • flow of − x from u to v • implies flow of x from v to u • can be cancelled by pushing x units from u to v • can then push another c ( u, v ) from u to v • can thus push total of x + c ( u, v ) > c ( u, v ) from u to v Maximum Flow 9

  10. Given flow network G = ( V, E ) and flow f , the residual network of G induced by f is G f = ( V, E f ) with E f = { ( u, v ) ∈ V × V : c f ( u, v ) > 0 } i.e. each residual edge that can admit flow that is strictly positive. 3 / 5 2 − → − → G u v = ⇒ G f u v ← − ← − 1 4 Note: | E f | ≤ 2 | E | . Maximum Flow 10

  11. Relationship between flow in residual network and flow in original network. Lemma 1. Let G = ( V, E ) be a flow network, f be a flow in G , G f be the residual network of G induced by f , and let f ′ be a flow in G f . Then flow sum f + f ′ with ( f + f ′ )( u, v ) = f ( u, v ) + f ′ ( u, v ) is a flow in G with value | f + f ′ | = | f | + | f ′ | . Proof. Must verify that skew symmetry, capacity constraints, and conservation are obeyed. Skew symmetry: ( f + f ′ )( u, v ) f ( u, v ) + f ′ ( u, v ) = − f ( v, u ) − f ′ ( v, u ) = − ( f ( v, u ) + f ′ ( v, u )) = − ( f + f ′ )( v, u ) = Maximum Flow 11

  12. Note f ′ is flow in G f , so f ′ ( u, v ) ≤ c f ( u, v ) . Capacity constraints: Since by def. c f ( u, v ) = c ( u, v ) − f ( u, v ) , ( 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 ) Flow conservation: For all u ∈ V − { s, t } , � ( f + f ′ )( u, v ) � ( f ( u, v ) + f ′ ( u, v )) = v ∈ V v ∈ V � � f ′ ( u, v ) = f ( u, v ) + v ∈ V v ∈ V = 0 + 0 = 0 Value: | f + f ′ | � ( f + f ′ )( s, v ) = v ∈ V � ( f ( s, v ) + f ′ ( s, v )) = v ∈ V � � f ′ ( s, v ) = f ( s, v ) + v ∈ V v ∈ V | f | + | f ′ | = Maximum Flow 12

  13. Augmenting paths Given flow network G = ( V, E ) and flow f , an augmenting path p is a simple path in residual network G f . Recall: each edge ( u, v ) in G f admits some additional positive flow, obeying capacity constraint. Flow value can be increased by c f ( p ) = min ( u,v ) ∈ p c f ( u, v ) . t 3/5 5/5 2/3 2/4 2/6 s G t 2 4 2 2 5 2 3 2 Gf s 1 In this example, augmentation by 2 . Maximum Flow 13

  14. Lemma. Let G = ( V, E ) be a flow network, f be a flow in G , and let p be an augmenting path in G f . Define f p : V × V → I R by  c f ( p ) if ( u, v ) is on p  f p ( u, v ) = − c f ( p ) if ( v, u ) is on p 0 otherwise  Then f p is a flow in G f with value | f p | = c f ( p ) > 0 . Corollary. Let G , f , p , f p be as above. Define f ′ : V × V → I R by f ′ = f + f p . Then f ′ is a flow in G with value | f ′ | = | f | + | f p | > | f | . Proof. From last two lemmas. Maximum Flow 14

  15. Cuts of flow networks A cut of flow network G = ( V, E ) is partition of V into S and T = V − S such that s ∈ S and t ∈ T . If f is a flow in G , then net flow across cut ( S, T ) is defined to be f ( S, T ) , capacity is c ( S, T ) . A minimum cut is a cut with minimum capacity over all cuts. 12/12 a c 11/16 15/20 1/4 s t 10 7/7 4/9 8/13 4/4 b d 11/14 S T Flow: f ( a, c ) + f ( b, c ) + f ( b, d ) = 12 + ( − 4) + 11 = 19 Note: can include negative flows. Capacity: c ( a, c ) + c ( b, d ) = 12 + 14 = 26 Note: only non-negative values, only edges going from S to T are being accounted for. Maximum Flow 15

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend