The Ford-Fulkerson Algorithm

Slides:



Advertisements
Similar presentations
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.
Advertisements

15.082J & 6.855J & ESD.78J October 14, 2010 Maximum Flows 2.
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)
1 Augmenting Path Algorithm s t G: Flow value = 0 0 flow capacity.
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.
The Out of Kilter Algorithm in Introduction The out of kilter algorithm is an example of a primal-dual algorithm. It works on both the primal.
Chapter 7 Maximum Flows: Polynomial Algorithms
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
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.
3 t s the black numbers next to an arc is its capacity.
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.
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.
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.
Maximization of Network Survivability against Intelligent and Malicious Attacks (Cont’d) Presented by Erion Lin.
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.
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.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 25.
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.
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 The Ford-Fulkerson Algorithm (aka the labeling algorithm) Updated 4 March 2008.
1 Maximum Flows CONTENTS Introduction to Maximum Flows (Section 6.1) Introduction to Minimum Cuts (Section 6.1) Applications of Maximum Flows (Section.
Ford-Fulkerson Recap.
St. Edward’s University
Lectures on Network Flows
EMIS 8374 Dijkstra’s Algorithm Updated 18 February 2008
Maximum Flow Problem flow capacity Actual flow  capacity
Network Flow 2016/04/12.
Instructor: Shengyu Zhang
The Shortest Augmenting Path Algorithm for the Maximum Flow Problem
Solving maximum flows on distribution networks:
Network Flow and Connectivity in Wireless Sensor Networks
Introduction to Maximum Flows
Introduction to Maximum Flows
Not Always Feasible 2 (3,5) 1 s (0,2) 3 (, u) t.
EMIS 8374 Shortest Path Problems: Introduction Updated 9 February 2008
Max Flow Min Cut, Bipartite Matching Yin Tat Lee
Complexity of Ford-Fulkerson
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
Shortest Path Problems
EE5900 Advanced Embedded System For Smart Infrastructure
and 6.855J March 6, 2003 Maximum Flows 2
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
Introduction to Maximum Flows
Maximum Flow Neil Tang 4/8/2008
Introduction to Minimum Cost Flows
Introduction to Maximum Flows
The Successive Shortest Path Algorithm
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
Maximum Flow Problems in 2005.
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
The Residual Network Given a flow x, the residual capacity rij of arc (i, j) is the maximum additional flow that can be sent from i to j using arcs (i,
Presentation transcript:

The Ford-Fulkerson Algorithm aka The Labeling Algorithm

Ford-Fulkerson Algorithm begin x := 0; label node t; while t is labeled do 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 remove a node i from LIST; for all {j in N: (i,j) in A and rij > 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

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

The Residual Network G(x) 2 2 4 4 5 1 6 4 t s 6 7 3 5 5

Iteration 1: LIST = {1}, Labeled = {1} 2 2 4 4 5 1 6 4 t s 6 7 3 5 5

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

Iteration 1: LIST = {2,3}, Labeled= {1,2,3} 4 3 5 6 7 pred(2) = 1 pred(3) = 1

Iteration 1: LIST = {2,3}, Labeled = {1,2,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

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

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

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

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

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 {rij: (i,j) in P) = 2 Send 2 units of flow from to s to t along path P

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

The Residual Network G(x) 2 4 2 3 2 1 6 2 2 4 t s 6 7 3 5 5

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

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

Iteration 2: LIST = {2,3}, Labeled = {1,2,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

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

Iteration 2: LIST = {3,5}, Labeled = {1,2,3,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) Arc (5,6) pred(6) = 5 label 6 LIST = {6}

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

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

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

The Residual Network G(x) 2 4 2 2 1 6 5 2 3 1 t s 6 4 3 5 5

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

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

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

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

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}

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

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

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

The Residual Network G(x) 2 4 2 2 1 6 5 2 3 1 t s 2 3 1 7 5 4 4

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

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

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

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

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

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

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

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

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.

Correctness: arcs in (S,T) j rij = 0 rij = uij - xij + xji 0 = uij – xij + xji xij = uij + xji Since xji must be at least zero and 0  xij  uij, it follows that xij = uij.

Correctness: arcs in (T,S) j s Suppose xij > 0 rji = uji – xji + xij Implies rji > 0 (uji  xji) Implies s can reach i in residual network which means i should have been labeled. Thus, xij = 0

Correctness Thus, the flows on the forward arcs in [S,T] are at the upper bound and there is no flow on any of the backwards arcs. This means x is a maximum flow by Property 6.1.

Complexity Let U = max {(i,j) in A} uij. If S = {s} and T = N\{s}, then u[S,T] is at most nU. The maximum flow is at most nU. 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(nU x m) = O(nmU).