EMIS 8374 The Ford-Fulkerson Algorithm (aka the labeling algorithm) Updated 4 March 2008.

Slides:



Advertisements
Similar presentations
15.082J & 6.855J & ESD.78J October 14, 2010 Maximum Flows 2.
Advertisements

1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
1 Maximum flow sender receiver Capacity constraint Lecture 6: Jan 25.
Chapter 5 Shortest Paths: Label-Correcting Algorithms
Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm.
Network Optimization Models: Maximum Flow Problems
MAXIMUM FLOW Max-Flow Min-Cut Theorem (Ford Fukerson’s Algorithm)
Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2012 Lecture 19.
1 Augmenting Path Algorithm s t G: Flow value = 0 0 flow capacity.
Chapter 10: Iterative Improvement The Maximum Flow Problem The Design and Analysis of Algorithms.
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
1 Maximum Flow Networks Suppose G = (V, E) is a directed network. Each edge (i,j) in E has an associated ‘capacity’ u ij. Goal: Determine the maximum amount.
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Chapter 7 Maximum Flows: Polynomial Algorithms
1 Augmenting Path Algorithm s t G: Flow value = 0 0 flow capacity.
Network Optimization Models: Maximum Flow Problems In this handout: The problem statement Solving by linear programming Augmenting path algorithm.
The max flow problem
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.
Minimum Cost Flow Lecture 5: Jan 25. Problems Recap Bipartite matchings General matchings Maximum flows Stable matchings Shortest paths Minimum spanning.
NetworkModel-1 Network Optimization Models. NetworkModel-2 Network Terminology A network consists of a set of nodes and arcs. The arcs may have some flow.
Chapter 4 Shortest Path Label-Setting Algorithms Introduction & Assumptions Applications Dijkstra’s Algorithm.
and 6.855J The Capacity Scaling Algorithm.
9/23/2015ACM-ICPC1 Maximum Flow Problem Source t fg e 42 Target (sink) flow capacity b s c a de 2/3/ actual flow 1/2/ 1/ 2/ 1.Actual flow  capacity.
Single Source Shortest-Path: The General Case (with negative edges) Bellman-Ford algorithm. Iteratively relax all edges |V|-1 times Running time? O(VE).
15.082J and 6.855J and ESD.78J October 19, 2010 Max Flows 3 Preflow-Push Algorithms.
1 COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf.
CS 4407, Algorithms University College Cork, Gregory M. Provan Network Optimization Models: Maximum Flow Problems In this handout: The problem statement.
Max Flow – Min Cut Problem. Directed Graph Applications Shortest Path Problem (Shortest path from one point to another) Max Flow problems (Maximum material.
1 WEEK 11 Graphs III Network Flow Problems A Simple Maximum-Flow Algorithm Izmir University of Economics.
Maximum Flow Problem (Thanks to Jim Orlin & MIT OCW)
& 6.855J & ESD.78J Algorithm Visualization The Ford-Fulkerson Augmenting Path Algorithm for the Maximum Flow Problem.
The Ford-Fulkerson Augmenting Path Algorithm for the Maximum Flow Problem Thanks to Jim Orlin & MIT OCW.
15.082J & 6.855J & ESD.78J October 7, 2010 Introduction to Maximum Flows.
15.082J and 6.855J March 4, 2003 Introduction to Maximum Flows.
15.082J and 6.855J and ESD.78J The Successive Shortest Path Algorithm and the Capacity Scaling Algorithm for the Minimum Cost Flow Problem.
and 6.855J March 6, 2003 Maximum Flows 2. 2 Network Reliability u Communication Network u What is the maximum number of arc disjoint paths from.
10/11/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 21 Network.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
Network Analysis Maxflow. What is a Network? Directed connected graph Source node Sink (destination node) Arcs are weighted (costs) Represent a system.
EMIS 8374 Shortest Path Trees Updated 11 February 2008 Slide 1.
Prof. Swarat Chaudhuri COMP 382: Reasoning about Algorithms Fall 2015.
Iterative Improvement for Domain-Specific Problems Lecturer: Jing Liu Homepage:
1 Maximum Flows CONTENTS Introduction to Maximum Flows (Section 6.1) Introduction to Minimum Cuts (Section 6.1) Applications of Maximum Flows (Section.
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
EMIS 8374 Dijkstra’s Algorithm Updated 18 February 2008
Maximum Flow Problem flow capacity Actual flow  capacity
The Shortest Augmenting Path Algorithm for the Maximum Flow Problem
Introduction to Maximum Flows
Lecture 4 Graph Search.
3.4 Push-Relabel(Preflow-Push) Maximum Flow Alg.
Lecture 19-Problem Solving 4 Incremental Method
Not Always Feasible 2 (3,5) 1 s (0,2) 3 (, u) t.
EMIS 8374 Shortest Path Problems: Introduction Updated 9 February 2008
Complexity of Ford-Fulkerson
EE5900 Advanced Embedded System For Smart Infrastructure
and 6.855J March 6, 2003 Maximum Flows 2
Introduction to Algorithms
The Shortest Augmenting Path Algorithm for the Maximum Flow Problem
The Shortest Augmenting Path Algorithm for the Maximum Flow Problem
EMIS 8374 Search Algorithms Updated 9 February 2004
The Ford-Fulkerson Algorithm
Introduction to Maximum Flows
and 6.855J Depth First Search
Introduction to Maximum Flows
Not Always Feasible 2 (3,5) 1 s (0,2) 3 (, u) t.
EMIS 8374 Search Algorithms Updated 12 February 2008
Max Flows 3 Preflow-Push Algorithms
Class 11 Max Flows Obtain a network, and use the same network to illustrate the shortest path problem for communication networks, the max flow.
Vertex Covers and Matchings
EMIS 8374 Max-Flow in Undirected Networks Updated 18 March 2008
Presentation transcript:

EMIS 8374 The Ford-Fulkerson Algorithm (aka the labeling algorithm) Updated 4 March 2008

Ford-Fulkerson Algorithm begin x := 0; label node t; while t is labeled do begin unlabel all nodes; pred(j) := 0 for all j in N; label s; LIST := {s}; while LIST is not empty and t is not labeled do begin remove a node i from LIST; for all {j in N: (i, j) in A and r ij > 0} do if j is unlabeled then pred(j) := i, label j, add j to LIST; end; if t is labeled then augment flow on path from s to t end; Slide 2

Labeling Algorithm Example s t (0,2) (0,6) 5 (0,5) 6 (0,4) (0,7) Slide 3

The Residual Network G(x) s t Slide 4

Iteration 1: LIST = {1}, Labeled = {1} s t i = 1 Slide 5

Iteration 1: LIST = {1}, Labeled = {1} i = 1 LIST = {} Arc (1,2) –pred(2) =1 –label 2 –LIST = {2} Arc (1,3) –pred (3) = 1 –label 3 –LIST = {2, 3} Slide 6

Iteration 1: LIST = {2,3}, Labeled= {1,2,3} s t pred(2) = 1 pred(3) = 1 Slide 7

Iteration 1: LIST = {2,3}, Labeled = {1,2,3} i = 2 LIST = {3} Arc (2,4) –pred(4) =2 –label 4 –LIST = {3,4} Arc (2,5) –pred (5) = 2 –label 5 –LIST = {3,4,5} Arc (2,1) –residual capacity of (2,1) = 0 Slide 8

Iteration 1: LIST = {3,4,5}, Labeled= {1,2,3,4,5} s t pred(2) = 1 pred(3) = 1pred(5) = 2 pred(4) = 2 Slide 9

Iteration 1: LIST = {3,4,5}, Labeled = {1,2,3,4,5} i = 3 LIST = {4,5} Arc (3,5) –5 is already labeled Arc (3,1) –residual capacity of (3,1) = 0 Slide 10

Iteration 1: LIST = {4,5}, Labeled = {1,2,3,4,5} i = 4 LIST = {5} Arc (4,2) –residual capacity of (4,2) = 0 Arc (4,6) –pred(6) =4 –label 6 –LIST = {5,6} Slide 11

Iteration 1: LIST = {5,6}, Labeled= {1,2,3,4,5,6} s t pred(2) = 1 pred(3) = 1pred(5) = 2 pred(4) = 2 pred(6) = 4 Slide 12

Iteration 1: The sink is labeled Use pred labels to trace back from the sink to the source to find path P –P = 1 → 2 → 4 → 6  = min {r ij : (i, j) in P) = 2 Send 2 units of flow from to s to t along path P Slide 13

Flow x After Iteration 1 s t (2,2) (0,6) 5 (0,5) 6 (2,5) (2,4) (0,4) (0,7) v = 2 Slide 14

The Residual Network G(x) s t Slide 15

Iteration 2: LIST = {1}, Labeled = {1} i = 1 LIST = {} Arc (1,2) –pred(2) =1 –label 2 –LIST = {2} Arc (1,3) –pred (3) = 1 –label 3 –LIST = {2, 3} Slide 16

Iteration 2: LIST = {2,3}, Labeled={1,2,3} s t p=1 Slide 17

Iteration 2: LIST = {2,3}, Labeled = {1,2,3} i = 2 LIST = {3} Arc (2,4) –residual cap (2,4) = 0 Arc (2,5) –pred (5) = 2 –label 5 –LIST = {3,5} Arc (2,1) –residual capacity of (2,1) = 0 Slide 18

Iteration 2: LIST = {3,5}, Labeled={1,2,3,5} s t p=1 p=2 Slide 19

Iteration 2: LIST = {3,5}, Labeled = {1,2,3,5} i = 3 LIST = {5} Arc (3,5) –5 is already labeled Arc (3,1) –residual capacity of (3,1) = 0 i = 5 LIST = {} Arc (5,2) –residual cap = 0 Arc (5,3) –residual cap = 0 Arc (5,6) –pred(6) = 5 –label 6 –LIST = {6} Slide 20

Iteration 2: LIST = {6}, Labeled={1,2,3,5,6} s t p=1 p=2 p=5 Slide 21

Iteration 2: The sink is labeled Use pred labels to trace back from the sink to the source to find path P –P = 1 -> 2 -> 5 -> 6  = min {rij: (i,j) in P) = 3 Send 3 units of flow from to s to t along path P Slide 22

Flow x After Iteration 2 s t (2,2) (0,6) 5 (0,5) 6 (5,5) (2,4) (3,4) (3,7) v = 5 Slide 23

The Residual Network G(x) s t Slide 24

Iteration 3: LIST = {1}, Labeled = {1} i = 1 LIST = {} Arc (1,2) –residual capacity = 0 Arc (1,3) –pred (3) = 1 –label 3 –LIST = {3} Slide 25

Iteration 3: List = {3}, Labeled = {1,3} s t p=1 Slide 26

Iteration 3: LIST = {3}, Labeled = {1,3} i = 3 LIST = {} Arc (3,1) –residual capacity = 0 Arc (3,5) –pred (5) = 3 –label 5 –LIST = {5} Slide 27

Iteration 3: List = {5}, Labeled = {1,3,5} s t p=1p=2 Slide 28

Iteration 3: LIST = {5}, Labeled = {1,3,5} i = 5, LIST = {} Arc (5,2) –pred(2) = 5 –label 2 –LIST = {2} Arc (5,3): residual capacity = 0 Arc (5,6) –pred (6) = 5 –label 6 –LIST = {2,6} Slide 29

Iteration 3: List = {2,6}, Labeled = {1,2,3,5,6} s t p=1p=2 p=5 Slide 30

Iteration 3: The sink is labeled Use pred labels to trace back from the sink to the source to find path P –P = 1 -> 3 -> 5 -> 6  = min {rij: (i,j) in P) = 4 Send 4 units of flow from to s to t along path P Slide 31

Flow x After Iteration 3 s t (2,2) (4,6) 5 (4,5) 6 (5,5) (2,4) (3,4) (7,7) v = 9 Slide 32

The Residual Network G(x) s t Slide 33

Iteration 4: LIST = {1}, Labeled = {1} i = 1 LIST = {} Arc (1,2) –residual capacity = 0 Arc (1,3) –pred (3) = 1 –label 3 –LIST = {3} Slide 34

Iteration 4: List = {3}, Labeled = {1,3} s t p=1 Slide 35

Iteration 4: LIST = {3}, Labeled = {1,3} i = 3 LIST = {} Arc (3,1) –1 is labeled Arc (3,5) –pred (5) = 3 –label 5 –LIST = {5} Slide 36

Iteration 4: List = {5}, Labeled = {1,3,5} s t p=1 p=3 Slide 37

Iteration 4: LIST = {5}, Labeled = {1,3,5} i = 5 LIST = {} Arc (5,2) –pred(2) = 5 –label 2 –LIST = {2} Arc (5,6) –residual capacity = 0 Slide 38

Iteration 4: List = {2}, Labeled = {1,2,3,5} s t p=1 p=3 p=5 Slide 39

Iteration 4: LIST = {2}, Labeled = {1,2,3,5} i = 2 LIST = {} Arc (2,1) –1 is already labeled Arc(2,4) –residual capacity = 0 Arc (2,5) –5 is already labeled Slide 40

Iteration 4 List = {} The sink is not labeled Algorithm ends with optimal flow x Slide 41

Correctness At the end of each iteration, the algorithm either augments the flow or terminates because it can’t label the sink. Let S be the set of labeled nodes when the algorithm terminates. Let T = N \ S. We need to show that when the algorithm terminates v = u[S, T] which implies x is a maximum flow. Slide 42

Correctness: arcs in (S, T) Slide 43 i j s

Correctness: arcs in (T, S) Implies s can reach node i in G(x) Implies i is labeled (i.e., node i is in S) Implies x ij = 0 Contradiction. If i in T and j in S, then x ij = 0 ij s Slide 44 Suppose x ij > 0 r ji = u ji – x ji + x ij Implies r ji > 0 since u ji  x ji

Complexity Let U = max {(i, j) in A} u ij. –If S = {s} and T = N\{s}, then u[S, T] ≤ nU. –The maximum flow is at most nU. –The inner loop runs at most nU times. An iteration of the inner while loop is O(m): –Each arc is inspected at most once –Finding  is O(n) –Updating the flow on P is O(n) Complexity is O(nmU). Slide 45

Pathological Example s (0,10 6 ) (0,1) t Slide 46

Pathological Example: First Augmenting Path s (0,10 6 ) (0,1) t Slide 47 v = 1

Residual Network s t Slide 48

An Augmenting Path in the Residual Network s t Slide 49

Updated Flow in G s (1,10 6 ) (0,1) t v = 2 Slide 50

Updated Residual Network s t Slide 51

Next Augmenting Path in the Residual Network s t This will take 2 million iterations to find the maximum flow! Slide 52

Polynomial Max Flow Algorithms (Chapter 7) Always augment along the shortest augmenting path in the residual network. –Use breadth-first search to find augmenting path –O(n 2 m) Always augment along the maximum-capacity augmenting path in the residual network. –O(nm log U) Goldberg’s algorithm (preflow-push) with highest-label implementation. –O(n 2 m 1/2 ) Slide 53