CS4234 Optimiz(s)ation Algorithms

Slides:



Advertisements
Similar presentations
Maximum flow Main goals of the lecture:
Advertisements

COMP 482: Design and Analysis of Algorithms
Lecture 5: Network Flow Algorithms Max-Flow Min-Cut Single-Source Shortest-Path (SSSP) Job Sequencing.
Max Flow Problem Given network N=(V,A), two nodes s,t of V, and capacities on the arcs: uij is the capacity on arc (i,j). Find non-negative flow fij for.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
1 Maximum flow sender receiver Capacity constraint Lecture 6: Jan 25.
MAXIMUM FLOW Max-Flow Min-Cut Theorem (Ford Fukerson’s Algorithm)
Chapter 10: Iterative Improvement The Maximum Flow Problem The Design and Analysis of Algorithms.
1 Maximum Flow w s v u t z 3/33/3 1/91/9 1/11/1 3/33/3 4/74/7 4/64/6 3/53/5 1/11/1 3/53/5 2/22/2 
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Lectures on Network Flows
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
1 Maximum flow problems. 2 - Introduction of: network, max-flow problem capacity, flow - Ford-Fulkerson method pseudo code, residual networks, augmenting.
Maximum Flows Lecture 4: Jan 19. Network transmission Given a directed graph G A source node s A sink node t Goal: To send as much information from s.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2004 Lecture 5 Wednesday, 10/6/04 Graph Algorithms: Part 2.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
MAX FLOW CS302, Spring 2013 David Kauchak. Admin.
Lecture 5: Network Flow Algorithms Single-Source Shortest-Path (SSSP) (Dijkstra's Algorithm) Max Flow - Min Cut (Ford-Fulkerson) Job Sequencing.
1 COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf.
Max Flow – Min Cut Problem. Directed Graph Applications Shortest Path Problem (Shortest path from one point to another) Max Flow problems (Maximum material.
Maximum Flow Problem (Thanks to Jim Orlin & MIT OCW)
Chapter 7 April 28 Network Flow.
15.082J and 6.855J March 4, 2003 Introduction to Maximum Flows.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 25.
Algorithm Design and Analysis (ADA)
Chapter 7 May 3 Ford-Fulkerson algorithm Step-by-step walk through of an example Worst-case number of augmentations Edmunds-Karp modification Time complexity.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
CSEP 521 Applied Algorithms Richard Anderson Lecture 8 Network Flow.
1 Network Flow CSC401 – Analysis of Algorithms Chapter 8 Network Flow Objectives: Flow networks –Flow –Cut Maximum flow –Augmenting path –Maximum flow.
Fall 2003Maximum Flow1 w s v u t z 3/33/3 1/91/9 1/11/1 3/33/3 4/74/7 4/64/6 3/53/5 1/11/1 3/53/5 2/22/2 
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
Theory of Computing Lecture 12 MAS 714 Hartmut Klauck.
Iterative Improvement for Domain-Specific Problems Lecturer: Jing Liu Homepage:
A directed graph G consists of a set V of vertices and a set E of arcs where each arc in E is associated with an ordered pair of vertices from V. V={0,
Minimum Cost Flow Algorithms and Networks. Algorithms and Networks: Minimum Cost Flow2 This lecture The minimum cost flow problem: statement and applications.
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Maximum Flow c v 3/3 4/6 1/1 4/7 t s 3/3 w 1/9 3/5 1/1 3/5 u z 2/2
Maximum Flow Chapter 26.
Lectures on Network Flows
Richard Anderson Lecture 23 Network Flow
Maximum Flow 9/13/2018 6:12 PM Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015.
Algorithms and Networks
Lecture 22 Network Flow, Part 2
CSCI 3160 Design and Analysis of Algorithms Tutorial 8
Network Flow 2016/04/12.
Instructor: Shengyu Zhang
Maximum Flow c v 3/3 4/6 1/1 4/7 t s 3/3 w 1/9 3/5 1/1 3/5 u z 2/2
CSE Algorithms Max Flow Problems 11/21/02 CSE Max Flow.
Maximum Flow c v 3/3 4/6 1/1 4/7 t s 3/3 w 1/9 3/5 1/1 3/5 u z 2/2
Network Flow and Connectivity in Wireless Sensor Networks
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 21 Network Flow
Flow Networks and Bipartite Matching
Max Flow Problem Given network N=(V,A), two nodes s,t of V, and capacities on the arcs: uij is the capacity on arc (i,j). Find non-negative flow fij for.
Algorithms (2IL15) – Lecture 7
Network Flow CSE 373 Data Structures.
EE5900 Advanced Embedded System For Smart Infrastructure
Algorithms and Networks
Maximum Flow c v 3/3 4/6 1/1 4/7 t s 3/3 w 1/9 3/5 1/1 3/5 u z 2/2
Text Book: Introduction to algorithms By C L R S
Network Flow.
Lecture 21 Network Flow, Part 1
Richard Anderson Lecture 22 Network Flow
Lecture 21 Network Flow, Part 1
Lecture 22 Network Flow, Part 2
Network Flow.
Richard Anderson Lecture 22 Network Flow
Advanced Graph Homer Lee 2013/10/31.
Presentation transcript:

CS4234 Optimiz(s)ation Algorithms v1.0: Seth Gilbert v1.1: Steven Halim CS4234 Optimiz(s)ation Algorithms L5 – Max-Flow/Min-Cut They are Primal-Dual LPs https://visualgo.net/en/maxflow

Types of Graph Problems (so far) 0. Connectivity: How is my network connected? P: (Strongly) Connected Component , https://visualgo.net/en/dfsbfs 1. Distances: How to get from here to there? P: Single-Source Shortest Paths, https://visualgo.net/en/sssp P: All-Pairs Shortest Paths 2. Spanning Trees: How do I design a network? P: Min-Spanning-Tree, https://visualgo.net/en/mst NP-hard: Steiner-Tee NP-hard: Travelling-Salesman, https://visualgo.net/en/tsp 3. Network Flows: How is my network connected? Our topic today (A TSP cycle – an edge = An SP tree) Not all graph problems are in P Not all graph problems are NP-hard Not all optimization problems are graph problems

Roadmap Network Flows Definition Ford-Fulkerson Algorithm Max-Flow/Min-Cut Theorem

Network Flow Problems Examples: Transportation problems Network attacks problems (Bipartite) Matching and Assignment problems Distributed network reliability Project selection Image segmentation Sport’s teams prospects 2016 status: Last three: Steven has not tried 2017 status: only project selection and sports team have not been tried

Network Flow (1/6) Input: directed graph G = (V, E) edge capacities c(e) source s destination/ target/sink t A 9 D 10 10 4 15 15 5 10 s B 8 E t 15 15 4 6 10 C 16 F capacity c(e) > 0

Network Flow (2/6) Output: Flow Assignment of flow f to each edge 2/9 A D 1/10 7/10 3/4 2/15 1/15 Example: capacity is 10: “c(e) = 10” flow is 7: “f(e) = 7” s 5/5 B 5/8 4/10 E t 0/15 4/4 1/6 4/15 7/10 C 4/16 F flow / capacity

Network Flow (3/6) Output: Flow Flow is not negative: For every edge e, 0 ≤ f(e) Flow ≤ capacity: For every edge e, f(e) ≤ c(e) 2/9 A D 1/10 7/10 3/4 2/15 1/15 5/5 4/10 s B 5/8 E t 0/15 4/4 1/6 4/15 7/10 C 4/16 F flow / capacity

Network Flow (4/6) Equilibrium constraint: For every vertex: Flow-in = Flow-out Except s and t 2/9 A D 1/10 7/10 3/4 2/15 1/15 Flow-in=5+2+1=8 s 5/5 5/8 4/10 B E t Flow-out=4+4=8 0/15 4/4 1/6 4/15 7/10 C 4/16 F

Network Flow (5/6) Output: st-flow Capacity constraint (never exceed capacity) Equilibrium constraint (Flow-in = Flow-out) 2/9 A D 1/10 7/10 3/4 2/15 1/15 5/5 4/10 s B 5/8 E t 0/15 4/4 1/6 4/15 7/10 C 4/16 F

Network Flow (6/6) Uni-directional flow: st-flow If f(u, v) > 0 and f(v, u) > 0, then they cancel out. Flows only go in one direction. 2/5 0/5 7/9 5/9

Value of a Flow (1/2) How much stuff gets from s to t? How much leaves source? How much gets to target? 2/9 A D 1/10 7/10 3/4 2/15 1/15 7+4+1=12 7+5=12 s 5/5 5/8 4/10 B E t 0/15 4/4 1/6 4/15 7/10 C 4/16 F

Value of a Flow (2/2) Definition: For a flow f: s t 7+4+1=12 7+5=12 2/9 A D 1/10 7/10 3/4 2/15 1/15 7+4+1=12 7+5=12 s 5/5 5/8 4/10 B E t 0/15 4/4 1/6 4/15 7/10 C 4/16 F

Max Flow (1/2) Goal: Find an st-flow with maximum value. s t 2/9 A D 1/10 7/10 3/4 2/15 1/15 5/5 4/10 s B 5/8 E t 0/15 4/4 1/6 4/15 7/10 value = 12 (not maximum yet) C 4/16 F

Max Flow (2/2) Goal: Find an st-flow with maximum value. Can be written as Linear Program (T04) 9/9 A D 9/10 10/10 0/4 1/15 0/15 5/5 9/10 s B 8/8 E t 13/15 0/4 3/6 0/15 10/10 value = 28 maximum C 13/16 F

Roadmap Network Flows Definition Ford-Fulkerson Algorithm Max-Flow/Min-Cut Theorem

(you can also try other flow graphs) Ford-Fulkerson (1/12) Initially: All flows are 0. Watch the animation live in VisuAlgo (chosen augmenting paths may be slightly different but the final answer is the same, max flow = 28) (you can also try other flow graphs) 0/9 A D 0/10 0/10 0/4 0/15 0/15 s 0/5 0/10 B 0/8 E t 0/15 0/4 0/6 0/15 0/10 value = 0 C 0/16 F

Ford-Fulkerson (2/12) Idea: Find an augmenting path (path from s to t that goes through edges with positive weight residual capacity (c(e)-f(e)) left) along which we can increase the flow. 0/9 A D 0/10 0/10 0/4 0/15 0/15 0/5 0/10 s B 0/8 E t 0/15 0/4 0/6 0/15 0/10 value = 0 C 0/16 F

Ford-Fulkerson (3/12) Augmenting path: Directed path from source s  sink t Can increase flow on all forward edges. First augmenting path s-A-E-t (+10) bottleneck 0/9 A D 0/10 10/10 0/4 10/15 0/15 s 0/5 10/10 B 0/8 E t 0/15 0/4 0/6 0/15 0/10 value = 0 + 10 C 0/16 F

Ford-Fulkerson (4/12) Augmenting path: Directed path from source s  sink t Can increase flow on all forward edges. Second augmenting path s-C-F-t (+10) 0/9 A D 0/10 10/10 0/4 10/15 0/15 0/5 10/10 s B 0/8 E t 10/15 0/4 0/6 0/15 10/10 value = 0 + 10 + 10 C 10/16 F

Ford-Fulkerson (5/12) Augmenting path: Directed path from source s  sink t Can increase flow on all forward edges. No more augmenting paths? Is max flow value = 20? 0/9 A D 0/10 10/10 0/4 10/15 0/15 0/5 10/10 s B 0/8 E t 10/15 0/4 0/6 0/15 10/10 value = 0 + 10 + 10 C 10/16 F

Ford-Fulkerson (6/12) Augmenting path: Directed path from source s  sink t Can increase flow on all forward edges. Third augmenting path s-B-E-A-D-t? (details TBA) No edge from EA? 0/9 A D 0/10 10/10 0/4 10/15 0/15 0/5 10/10 s B 0/8 E t 10/15 0/4 0/6 0/15 10/10 value = 0 + 10 + 10 C 10/16 F

Ford-Fulkerson (7/12) Augmenting path: Undirected path from source s  sink t Can increase flow on all forward edges OR Can decrease flow on backward edges (details TBA) Third augmenting path s-B-E-A-D-t (+5) 5/9 A D 5/10 10/10 0/4 (10-5)/15 0/15 5/5 10/10 s B 5/8 E t 10/15 0/4 0/6 0/15 10/10 value = 0 + 10 + 10 + 5 C 10/16 F

Ford-Fulkerson (8/12) Augmenting path: Undirected path from source s  sink t Can increase flow on all forward edges OR Can decrease flow on backward edges (details TBA) Fourth augmenting path s-C-F-B-E-A-D-t (+3) 5+3/9 A D 5+3/10 10/10 0/4 (10-5-3)/15 0/15 5/5 10/10 s B 5+3/8 E t 10+3/15 0/4 0+3/6 0/15 10/10 C 10+3/16 F value = 0 + 10 + 10 + 5 + 3 = 28

Ford-Fulkerson (9/12) Augmenting path: Undirected path from source s  sink t Can increase flow on all forward edges OR Can decrease flow on backward edges (details TBA) No more augmenting paths? This time yes 8/9 A D 8/10 10/10 0/4 2/15 0/15 10/10 s 5/5 B 8/8 E t 13/15 0/4 3/6 0/15 10/10 C 13/16 F value = 28 No more augmenting paths.

Ford-Fulkerson (10/12) Augmenting path: Undirected path from source s  sink t Can increase flow on all forward edges OR Can decrease flow on backward edges (details TBA) 8/9 A D saturated 8/10 10/10 0/4 2/15 0/15 s 5/5 B 8/8 10/10 E t 13/15 0/4 3/6 0/15 10/10 C 13/16 F value = 28 saturated

Ford-Fulkerson (11/12) Augmenting path: Undirected path from source s  sink t Can increase flow on all forward edges OR Can decrease flow on backward edges (details TBA) 8/9 A D saturated 10/10 0/4 8/10 2/15 0/15 5/5 8/8 10/10 s B E t 0/15 s-component = {s,B,C,F} (details later) 13/15 0/4 3/6 10/10 C 13/16 F value = 28 saturated

Ford-Fulkerson (12/12) Augmenting path: Undirected path from source s  sink t Can increase flow on all forward edges OR Can decrease flow on backward edges (details TBA) 8/9 A D empty 10/10 0/4 8/10 2/15 0/15 5/5 8/8 10/10 s B E t 0/15 s-component = {s,B,C,F} (details later) 13/15 0/4 3/6 10/10 C 13/16 F value = 28 empty

Ford-Fulkerson (Basic Idea) Ford-Fulkerson Algorithm Start with 0 flow. While there exists an augmenting path: // iterative algorithm Find an augmenting path. Compute bottleneck capacity. Increase flow on the path by the bottleneck capacity. There are still a few missing details: How to find an augmenting path? Does Ford-Fulkerson always terminate? How fast? If it terminates, does it always find a max-flow?

Initial graph: flow = 0  residual = capacity. Finding an Augmenting Path (1/15) Residual Graph: Amount that flow can be increased residual(e) = capacity(e) – flow(e) 9 A D 10 10 4 15 15 5 10 s B 8 E t 15 4 6 15 10 C 16 F Initial graph: flow = 0  residual = capacity.

Step 1: augmenting path s-A-E-t of flow 10. Finding an Augmenting Path (2/15) Residual Graph: Amount that flow can be increased residual(e) = capacity(e) – flow(e) 9 A D 10 10-10 4 15-10 15 5 10-10 s B 8 E t 15 4 6 15 10 C 16 F Step 1: augmenting path s-A-E-t of flow 10.

After augmenting path s-A-E-t of flow 10. Finding an Augmenting Path (3/15) Residual Graph: Amount that flow can be increased residual(e) = capacity(e) – flow(e) 9 A D 10 4 5 15 5 s B 8 E t 15 4 6 15 10 C 16 F After augmenting path s-A-E-t of flow 10.

How best to find an augmenting path in the residual graph? For now, any O(V+E) graph traversal algorithm will do (BFS, DFS, etc.) Any path from st in the residual graph is an augmenting path. 30 of 60

Step 2: augmenting path s-C-F-t of flow 10. Finding an Augmenting Path (4/15) Residual Graph: Amount that flow can be increased residual(e) = capacity(e) – flow(e) 9 A D 10 4 5 15 5 s B 8 E t 15-10 4 6 15 10-10 C 16-10 F Step 2: augmenting path s-C-F-t of flow 10.

After step 2: augmenting path s-C-F-t of flow 10… stuck? Finding an Augmenting Path (5/15) Residual Graph: Amount that flow can be increased residual(e) = capacity(e) – flow(e) 9 A D 10 4 5 15 5 s B 8 E t 5 4 6 15 C 6 F After step 2: augmenting path s-C-F-t of flow 10… stuck?

Finding an Augmenting Path (6/15) Residual Graph: Amount that flow can be increased residual(e) = capacity(e) – flow(e) 9 A D 10 10 4 15 15 5 8 10 s B E t 4 6 15 10 15 C 16 F To simplify the algorithm: We add edges in both direction in residual graph.

Finding an Augmenting Path (7/15) Residual Graph: Amount that flow can be increased residual(e) = capacity(e) – flow(e) 9 A D 10-10 0+10 10 0+10 4 15-10 15 5 8 10-10 s B E t 0+10 4 6 15 10 15 C 16 F Augmenting path 1: s-A-E-t (+10): Residual flow in the other direction.

Finding an Augmenting Path (8/15) Residual Graph: Amount that flow can be increased residual(e) = capacity(e) – flow(e) 9 A D 10 10 10 4 5 15 5 8 s B E t 10 4 6 15 10 15 C 16 F Augmenting path 1: s-A-E-t (+10): Residual flow in the other direction.

Augmenting path 2: s-C-F-t (+10) Finding an Augmenting Path (9/15) Residual Graph: Amount that flow can be increased residual(e) = capacity(e) – flow(e) 9 A D 10 10 10 4 5 15 5 8 s B E t 10 4 6 15 10 15 C 16 F Augmenting path 2: s-C-F-t (+10)

Augmenting path 2: s-C-F-t (+10) Finding an Augmenting Path (10/15) Residual Graph: Amount that flow can be increased residual(e) = capacity(e) – flow(e) 9 A D 10 10 10 4 5 15 5 8 s B E t 10 4 6 15 10 5 10 C 6 F 10 Augmenting path 2: s-C-F-t (+10)

Augmenting path 3: s-B-E-A-D-t (+5) Finding an Augmenting Path (11/15) Residual Graph: Amount that flow can be increased residual(e) = capacity(e) – flow(e) 9 A D 10 10 10 4 5 15 5 8 s B E t 10 4 6 15 10 5 10 C 6 F 10 Augmenting path 3: s-B-E-A-D-t (+5)

Augmenting path 3: s-B-E-A-D-t (+5) Finding an Augmenting Path (12/15) Residual Graph: Amount that flow can be increased residual(e) = capacity(e) – flow(e) 5 4 A D 5 5 10 5 10 4 15 s 3 B E t 5 5 10 4 6 15 10 5 10 C 6 F 10 Augmenting path 3: s-B-E-A-D-t (+5)

Augmenting path 4: s-C-F-B-E-A-D-t (+3) Finding an Augmenting Path (13/15) Residual Graph: Amount that flow can be increased residual(e) = capacity(e) – flow(e) 5 4 A D 5 5 10 5 10 4 15 s 3 B E t 5 5 10 4 6 15 10 5 10 C 6 F 10 Augmenting path 4: s-C-F-B-E-A-D-t (+3)

Augmenting path 4: s-C-F-B-E-A-D-t (+3) Finding an Augmenting Path (14/15) Residual Graph: Amount that flow can be increased residual(e) = capacity(e) – flow(e) 8 1 A D 8 2 13 2 10 4 15 s B E t 5 8 10 4 3 15 13 2 3 10 C 3 F 13 Augmenting path 4: s-C-F-B-E-A-D-t (+3)

No more augmenting path, Forward flow = Reverse residual flow. Finding an Augmenting Path (15/15) Residual Graph: Amount that flow can be increased residual(e) = capacity(e) – flow(e) 8 1 A D 8 2 13 2 10 4 15 s B E t 5 8 10 4 3 15 13 2 3 10 C 3 F 13 No more augmenting path, Forward flow = Reverse residual flow.

Ford-Fulkerson (More Complete) Ford-Fulkerson Algorithm Start with 0 flow. Build residual graph: For every edge (u,v) add edge (u,v) with w(u,v) = capacity. For every edge (u,v) add (a new) edge (v,u) with w(v,u) = 0. While there exists an augmenting path: Find an augmenting path via DFS in residual graph. Compute bottleneck capacity. Increase flow on the path by the bottleneck capacity: For every edge (u,v) on the path, subtract the flow from w(u,v). For every edge (u,v) on the path, add the flow to w(v,u). Compute final flow by inverting residual flows. Be careful of potential bug here

Ford-Fulkerson Details: How to find an augmenting path? Ford-Fulkerson Algorithm Start with 0 flow. While there exists an augmenting path: Find an augmenting path. Compute bottleneck capacity. Increase flow on the path by the bottleneck capacity. Details: How to find an augmenting path? Does Ford-Fulkerson always terminate? How fast? If it terminates, does it always find a max-flow?

Roadmap Network Flows Definition Ford-Fulkerson Algorithm Max-Flow/Min-Cut Theorem

One possible st-cut, set S = blue, set T = green Cuts and Flows – Definition (1/4) Definition: An st-cut partitions the vertices of a graph into two disjoint sets S and T where source s  S and sink t  T. PS: Hard to see the colors in b/w print… >< A 9 D 10 10 4 15 15 s 5 B 8 E 10 t 15 15 4 6 10 C 16 F One possible st-cut, set S = blue, set T = green

Another possible st-cut, set S = blue, set T = green Cuts and Flows – Definition (2/4) Definition: An st-cut partitions the vertices of a graph into two disjoint sets S and T where source s  S and sink t  T. A s C F E B t D 10 5 15 4 9 6 16 8 Another possible st-cut, set S = blue, set T = green

Capacity of this st-cut = 48 Cuts and Flows – Definition (3/4) Definition: The capacity of an st-cut is the sum of the capacities of the edges that cross the cut from S to T. A 9 D 10 10 4 15 15 s 5 10 B 8 E t 15 15 4 6 10 C 16 F Capacity of this st-cut = 48

What is the capacity of this st-cut? 9 D 10 10 4 15 15 s 5 10 B 8 E t 15 15 4 6 10 C 16 F Capacity of this st-cut = 45 29 of 60

Cuts and Flows – Definition (4/4) The net flow across an st-cut is the sum of the flows on edges from ST minus the flows from TS. A 5/9 D 10 10 4 3/15 15 s 5 10 B 4/8 E t 15 15 4 5/6 10 Capacity = 48 Net flow = 9 C 2/16 F

Cuts and Flows – Equal (1/4) Proposition: Let f be a flow, and let (S,T) be an st-cut. Then the net flow across (S,T) equals the value of f. A 2/9 D 1/10 7/10 3/4 2/15 1/15 s 5/5 B 5/8 E 4/10 t 0/15 4/4 1/6 4/15 7/10 C 4/16 F Value of flow = 12

Cuts and Flows – Equal (2/4) Proposition: Let f be a flow, and let (S,T) be an st-cut. Then the net flow across (S,T) equals the value of f. A 2/9 D 1/10 7/10 3/4 2/15 1/15 s 5/5 B 5/8 E 4/10 t 0/15 4/4 1/6 4/15 7/10 C 4/16 F Flow across cut = 12 Value of flow = 12

Cuts and Flows – Equal (3/4) Proposition: Let f be a flow, and let (S,T) be an st-cut. Then the net flow across (S,T) equals the value of f. A 2/9 D 1/10 7/10 3/4 2/15 1/15 s 5/5 B 5/8 E 4/10 t 0/15 4/4 1/6 4/15 7/10 C 4/16 F Flow across cut = 12 Value of flow = 12

Cuts and Flows – Equal (4/4) Proposition: Let f be a flow, and let (S,T) be an st-cut. Then the net flow across (S,T) equals the value of f. A 2/9 D 1/10 7/10 3/4 2/15 1/15 s 5/5 B 5/8 E 4/10 t 0/15 4/4 1/6 4/15 7/10 C 4/16 F Flow across cut = 12 Value of flow = 12

Cuts and Flows – Equal Proof (1/5) Proof: (by induction) Start with S = {source s}, T = V \ S. Define F = flow across cut. 2/9 A D 7/10 1/10 3/4 2/15 1/15 5/5 4/10 s B 5/8 E t 0/15 4/4 1/6 4/15 7/10 F = 12 4/16 C F

Cuts and Flows – Equal Proof (2/5) Inductive step: Take one node X that is reachable from S and add it to S. Add new outgoing edges that cross new cut. Subtract new incoming edges that cross new cut. Subtract/add edges from A to S. 2/9 A D 7/10 1/10 3/4 2/15 1/15 5/5 4/10 s B 5/8 E t 0/15 4/4 1/6 4/15 7/10 F + (3 + 2 + 2) – 7 = F 4/16 C F

Cuts and Flows – Equal Proof (3/5) Inductive step: Conservation of flow: (Equilibrium constraint) Flow into A equals flow out of A. Flow that crossed (old S)A == A(old T) So F remains unchanged 2/9 A D 7/10 3/4 2/15 1/10 1/15 s 5/5 B 5/8 4/10 E t 0/15 4/4 1/6 4/15 7/10 F + (3 + 2 + 2) – 7 = F 4/16 C F

Cuts and Flows – Equal Proof (4/5) Proof: (by induction) Start with S = {source s}, T = V \ S. Define F = flow across cut. Move vertices one at a time from T to S. At every step, F remains unchanged. Thus for all cuts, flow is F. 2/9 A D 7/10 1/10 3/4 2/15 1/15 5/5 4/10 s B 5/8 E t 0/15 4/4 1/6 4/15 7/10 4/16 C F

Cuts and Flows – Equal Proof (5/5) Proof: (by induction) What is F? Consider cut S = V \ {sink t}, T = {sink t}. All edges crossing the cut go to sink t. Value of flow = flow across cut = F. 2/9 A D 7/10 1/10 3/4 2/15 1/15 5/5 4/10 s B 5/8 E t 0/15 4/4 1/6 4/15 7/10 4/16 C F

Cuts and Flows – Weak Duality (1/2) Let f be a flow, and let (S,T) be an st-cut. Then value(f)  capacity(S,T). A 2/9 D 1/10 7/10 3/4 2/15 1/15 s 5/5 B 5/8 E 4/10 t 0/15 4/4 1/6 4/15 7/10 C 4/16 F

Cuts and Flows – Weak Duality (2/2) Let f be a flow, and let (S,T) be an st-cut. Then value(f)  capacity(S,T). Proof: value(f) = flow across cut (S,T)  capacity(S,T). flow value proposition flow is bounded by the capacity

MaxFlow-MinCut Theorem Let f be a maximum flow. Let (S,T) be an st-cut with minimum capacity. Then value(f) = capacity(S,T). A 2/9 D 1/10 7/10 3/4 2/15 1/15 s 5/5 B 5/8 E 4/10 t 0/15 4/4 1/6 4/15 7/10 C 4/16 F

Augmenting Path Theorem Flow f is a maximum flow if and only if there are no augmenting paths in the residual graph. A 2/9 D 1/10 7/10 3/4 2/15 1/15 s 5/5 B 5/8 E 4/10 t 0/15 4/4 1/6 4/15 7/10 C 4/16 F

Cuts and Flows – 3 Statements Proof: The following three statements are equivalent for flow f: There exists a cut whose capacity equals the value of f. f is a maximum flow. There is no augmenting path with respect to f.

Cuts and Flows – Statement 12 1  2: There exists an f-capacity cut  f is maximum Assume (S,T) is a cut with capacity equal to f. For all flows g: value(g)  capacity(S,T) For all flows g: value(g)  value(f) f is a maximum flow weak duality

Cuts and Flows – Statement 23 2  3: f is maximum flow  no augmenting paths Assume there IS at least 1 more augmenting path: Improve flow by sending flow on augmenting path. Augmenting path has bottleneck capacity > 0. f was NOT a maximum flow. Contradiction.

Cuts and Flows – Statement 31 (1/4) 3  1: no augmenting paths  exists f-capacity cut Assume there is no augmenting path: Let S be the vertices reachable from the source in the residual graph. Let T be the remaining vertices, i.e. T = V \ S. A 9/9 D 9/10 10/10 0/4 1/15 0/15 s 5/5 B 8/8 E 9/10 t 13/15 0/15 0/4 3/6 10/10 C 13/16 F

Cuts and Flows – Statement 31 (2/4) 3  1: no augmenting paths  exists f-capacity cut Assume there is no augmenting path: Let S = reachable vertices. T = remaining vertices. S contains the source s and T contains the target/sink t. source s cannot reach sink t anymore Otherwise, if sink t was reachable from source s in the residual graph, there would be another augmenting path. A s C F E B t D 10/10 5/5 13/15 0/4 9/9 3/6 1/15 0/15 9/10 13/16 8/8

Cuts and Flows – Statement 31 (3/4) 3  1: no augmenting paths  exists f-capacity cut Assume there is no augmenting path: Let S = reachable vertices. T = remaining vertices. (S,T) is an st-cut. All edges from TS are empty. All edges from ST are saturated. A s C F E B t D 10/10 5/5 13/15 0/4 9/9 3/6 1/15 0/15 9/10 13/16 8/8 T->S empty: Otherwise, there would be an outgoing edge in the residual graph.

Cuts and Flows – Statement 31 (4/4) 3  1: no augmenting paths  exists f-capacity cut Assume there is no augmenting path: Let S = reachable vertices. T = remaining vertices. (S,T) is an st-cut. All edges from TS are empty. All edges from ST are saturated. value(f) = net flow across (S,T) = capacity of cut Notice  changed to = ST saturation TS empty flow value proposition

Summary Augmenting Path Theorem: Flow f is a maximum flow if and only if there are no augmenting paths in the residual graph.  If Ford-Fulkerson terminates, then there is no augmenting path. Thus, the resulting flow is maximum.

Finding Min Cut (1/2) How to find a min-cut: Run Ford-Fulkerson until termination. Let S be the set of vertices reachable from the source s: Run DFS in the residual graph. All the vertices reach are in S. For every edge in S, enumerate outgoing edges: If edge exits S, add to min-cut. If both ends of edge are in S, then continue.

Finding Min Cut (2/2) Finding a minimum cut: Assume there is no augmenting path: Let S = reachable vertices. T = remaining vertices. (S,T) is an st-cut. Edges from (ST) are minimum cut. A s C F E B t D 10/10 5/5 13/15 0/4 9/9 3/6 1/15 0/15 9/10 13/16 8/8

Ford-Fulkerson (Yet More Details 1/3) Ford-Fulkerson Algorithm Start with 0 flow. While there exists an augmenting path: Find an augmenting path. Compute bottleneck capacity. Increase flow on the path by the bottleneck capacity. Termination: Ford-Fulkerson always terminates. How to find an augmenting path? If it terminates, does it always find a max-flow? Does Ford-Fulkerson always terminate? How fast?

Ford-Fulkerson (Yet More Details 2/3) Ford-Fulkerson Algorithm Start with 0 flow. While there exists an augmenting path: Find an augmenting path. Compute bottleneck capacity. Increase flow on the path by the bottleneck capacity. Termination: FF terminates if capacities are integers. Every iteration finds a new augmenting path. Each augmenting path has bottleneck capacity at least 1. So each iteration increases the flow of at least one edge by at least 1. Finite number of edges, finite max capacity per edge  termination.

Ford-Fulkerson (Yet More Details 3/3) Ford-Fulkerson Algorithm Start with 0 flow. While there exists an augmenting path: Find an augmenting path. Compute bottleneck capacity. Increase flow on the path by the bottleneck capacity. Termination: Ford-Fulkerson always terminates. How to find an augmenting path? If it terminates, does it always find a max-flow? How fast does Ford-Fulkerson terminate? Can we do better? Next lecture…