Max Flow / Min Cut.

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)
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.
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
1 COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
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.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
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.
Network Flow. Network flow formulation A network G = (V, E). Capacity c(u, v)  0 for edge (u, v). Assume c(u, v) = 0 if (u, v)  E. Source s and sink.
Max Flow – Min Cut Problem. Directed Graph Applications Shortest Path Problem (Shortest path from one point to another) Max Flow problems (Maximum material.
Chapter 7 April 28 Network Flow.
15.082J and 6.855J March 4, 2003 Introduction to Maximum Flows.
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.
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,
Ford-Fulkerson Recap.
Network Flow What is a network? Flow network and flows
Maximum Flow Chapter 26.
The Maximum Network Flow Problem
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
Max-flow, Min-cut Network flow.
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Graph Algorithms Minimum Spanning Tree (Chap 23)
CS4234 Optimiz(s)ation Algorithms
Algorithm Design and Analysis
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.
Lecture 22 Network Flow, Part 2
CSCI 3160 Design and Analysis of Algorithms Tutorial 8
Max Flow min Cut.
Max-flow, Min-cut Network flow.
Network Flow 2016/04/12.
Instructor: Shengyu Zhang
Edmonds-Karp Algorithm
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.
Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Network Flow and Connectivity in Wireless Sensor Networks
Flow Networks Topics Flow Networks Residual networks
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 21 Network Flow
Flow Networks General Characteristics Applications
Flow Networks and Bipartite Matching
Algorithms (2IL15) – Lecture 7
Network Flow CSE 373 Data Structures.
EE5900 Advanced Embedded System For Smart Infrastructure
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.
Lecture 21 Network Flow, Part 1
MAXIMUM flow by Eric Wengert.
Richard Anderson Lecture 22 Network Flow
Lecture 21 Network Flow, Part 1
Maximum Flow Neil Tang 4/8/2008
Lecture 22 Network Flow, Part 2
Network Flow.
Richard Anderson Lecture 22 Network Flow
Maximum Flow Problems in 2005.
Presentation transcript:

Max Flow / Min Cut

Max Flow Given a directed graph G with a special source node s, a special sink node t s has no inbound edges, and t has no outbound edges For each edge e in the graph, c(e) is the given “capacity” of the edge The capacity must be greater than 0 For simplicity, assume the capacity is an integer or ∞ Define f(e) to be the “flow” along an edge The flow must be non-negative The flow must also no greater than the capacity for a given edge For any given node, the sum of flows of inbound edges must equal the sum of flows of outbound edges (“conservation of flow”) Exceptions: s may have any amount of outbound flow, and t may have any amount of inbound flow Question: what is the maximum amount of flow that can be sent from s to t?

Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 0/2 0/2 0/3 0/15

Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 0/2 0/2 0/3 0/15

Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 0/2 0/2 0/3 15/15

Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 0/2 0/2 0/3 15/15

Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 2/2 0/2 3/3 6/15 1/1 h

Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 2/2 0/2 3/3 6/15 1/1 h

Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 0/2 0/2 0/3 0/15

Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 0/2 0/2 0/3 0/15

Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 0/2 0/2 0/3 0/15

Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 0/2 2/2 2/3 2/15

Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 0/2 2/2 2/3 2/15

Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 0/2 2/2 2/3 2/15

Max Flow d a e s t g b h 0/10 3/∞ 3/4 3/3 0/∞ 3/10 0/2 2/2 2/3 2/15

Max Flow d a e s t g b h 0/10 3/∞ 3/4 3/3 0/∞ 3/10 0/2 2/2 2/3 2/15

Max Flow d a e s t g b h 0/10 3/∞ 3/4 3/3 0/∞ 3/10 0/2 2/2 2/3 2/15

Max Flow d a e s t g b h 0/10 3/∞ 3/4 3/3 0/∞ 3/10 0/2 2/2 2/3 2/15

Max Flow d a e s t g b h 0/10 4/∞ 4/4 3/3 0/∞ 4/10 1/2 2/2 2/3 3/15

Max Flow d a e s t g b h 0/10 4/∞ 4/4 3/3 0/∞ 4/10 1/2 2/2 2/3 3/15

Max Flow d a e s t g b h 1/10 5/∞ 4/4 3/3 0/∞ 4/10 2/2 2/2 2/3 4/15 0/1 0/1 h

Max Flow d a e s t g b h 1/10 5/∞ 4/4 3/3 0/∞ 4/10 2/2 2/2 2/3 4/15 0/1 0/1 h

Max Flow d a e s t g b h 1/10 5/∞ 4/4 3/3 0/∞ 4/10 2/2 2/2 2/3 5/15

Max Flow d a e s t g b h 1/10 5/∞ 4/4 3/3 0/∞ 4/10 2/2 2/2 2/3 5/15

Max Flow d a e s t g b h 1/10 5/∞ 4/4 3/3 0/∞ 4/10 2/2 2/2 2/3 5/15

Max Flow d a e s t g b h 1/10 5/∞ 4/4 3/3 0/∞ 4/10 2/2 2/2 2/3 5/15

Max Flow d a e s t g b h 1/10 5/∞ 4/4 3/3 0/∞ 4/10 2/2 2/2 2/3 5/15

Max Flow d a e s t g b h 1/10 5/∞ 4/4 3/3 0/∞ 4/10 2/2 2/2 2/3 5/15

Max Flow / Min Cut Define a “cut” to be a partition of the nodes into two sets. An s-t cut is one where one set contains s and the other contains t Define the capacity of an s-t cut to be the sum of the capacities of the edges that “cross the partition boundary” from the s set to the t set In other words, if the nodes are partitioned into sets A and B with s ∈ A and t ∈ B, the edges from u to v where u ∈ A and v ∈ B The Min Cut problem is to find the s-t cut with the minimum capacity The Max Flow / Min Cut Theorem says the answers are the same! Essentially formalizes the notion of “bottlenecks” ...but does our bottleneck finding/saturating algorithm always work?

Max Flow v 0/3 0/2 s t 0/5 0/2 0/3 w

Max Flow v 0/3 0/2 s t 0/5 0/2 0/3 w

Max Flow v 3/3 0/2 s t 3/5 0/2 3/3 w

Max Flow v 3/3 0/2 s t 3/5 0/2 3/3 w Max flow = 3 ?

Max Flow v 3/3 0/2 s t 3/5 0/2 3/3 w Max flow = 3 ?

Max Flow v 3/3 0/2 s t 3/5 0/2 3/3 w Max flow = 3 ?

Max Flow v 3/3 0/2 s t 3/5 0/2 3/3 w Max flow = 3 ?

Max Flow v 3/3 0/2 s t 3/5 0/2 3/3 w Max flow = 3 ?

Max Flow v 0/3 0/2 s t 0/5 0/2 0/3 w

Max Flow v 0/3 0/2 s t 0/5 0/2 0/3 w

Max Flow v 2/3 2/2 s t 0/5 0/2 0/3 w

Max Flow v 2/3 2/2 s t 0/5 0/2 0/3 w

Max Flow v 2/3 2/2 s t 0/5 0/2 0/3 w

Max Flow v 2/3 2/2 s t 0/5 2/2 2/3 w

Max Flow v 2/3 2/2 s t 0/5 2/2 2/3 w

Max Flow v 2/3 2/2 s t 0/5 2/2 2/3 w

Max Flow v 3/3 2/2 s t 1/5 2/2 3/3 w

Max Flow v 3/3 2/2 s t 1/5 2/2 3/3 w Max flow = 5 !

Max Flow Being greedy isn’t quite good enough At least, the order you pick the paths seems to matter Key idea: just because we *can* saturate a path doesn’t necessarily mean we *should* We want to be able to “undo” choices if it turns out they boxed us in a corner Solution: “residual graphs” Augment the graph with information that allows algorithm to “undo” or “push flow back”

Max Flow v 0/3 0/2 s t 0/5 0/2 0/3 w

Max Flow v v s t s t w w Original Graph Residual Graph 3 2 0/3 0/2 5 0/5 2 3 0/2 0/3 w w

Max Flow v v s t s t w w Original Graph Residual Graph 3 2 0/3 0/2 5 0/5 2 3 0/2 0/3 w w

Max Flow v v s t s t w w Original Graph Residual Graph 3 2 3/3 0/2 2 3 3/5 2 3 0/2 3/3 w w

Max Flow v v s t s t w w Original Graph Residual Graph 3 2 3/3 0/2 2 3 3/5 2 3 0/2 3/3 w w

Max Flow v v s t s t w w Original Graph Residual Graph 3 2 3/3 0/2 2 3 3/5 2 3 0/2 3/3 w w

Max Flow v v s t s t w w Original Graph Residual Graph 3 2 3/3 2/2 4 1 1/5 2 3 2/2 3/3 w w

Max Flow v v s t s t w w Original Graph Residual Graph 3 2 3/3 2/2 4 1 1/5 2 3 2/2 3/3 w w

Max Flow: Ford-Fulkerson Method Given graph G, define GR (the residual graph) to be the same graph but with only capacity (no flow) and capacities denoted by cR(e). Maintain that for any edge (u, v) in G that cR(u, v) + cR(v, u) = c(u, v) Called “skew symmetry” While there’s a path P from s to t in GR: Find the minimum capacity cR among all edges in P, call it m For each edge (u, v) in P: If (u, v) in G, update f(u, v) += m Otherwise, (v, u) is in G so update f(v, u) -= m Update cR(u, v) and cR(v, u) accordingly to match remaining capacity in G and maintain skew symmetry Called a “method” because the path finding mechanism is not explicitly defined If you use Breadth-First search, it’s called the Edmonds-Karp algorithm

Max Flow: Applications Many seemingly unrelated problems map nicely into a network flow equivalent Useful fact: If all edge capacities are integers, the max flow will also be an integer (and the flow along any given edge will also be an integer) Known as the Integral Flow Theorem

Max Flow: Network Connectivity You have two computers that are indirectly connected through a network of other computer systems. How many internal network disconnections is your connection resilient to? s t 0/1

Max Flow: Network Connectivity You have two computers that are indirectly connected through a network of other computer systems. How many internal network disconnections is your connection resilient to? 1/1 1/1 1/1 0/1 1/1 1/1 s t 0/1 0/1 0/1 0/1

Max Flow: School Dance Boys and girls need to be paired up for the school dance, but the kids only want to be paired with someone that they know. Is such a pairing possible? And if so, what’s the pairing? s b1 b2 b3 b4 g1 g2 g3 g4 t (all capacities = 1)

Min Cut: Project Selection You have a set of projects pi which will each net a revenue of r(pi). Each project will require purchasing one or more machines qj each of which costs c(qj). Machines can be shared by multiple projects. The goal is to maximize profit. Let P̄ be the set of projects NOT taken, and Q be the set of machines purchased. Then we want: max [ ∑i r(pi) - ∑pi∈ P̄ r(pi) - ∑pj∈ Q c(qj) ] Which can be reformulated as: ∑i r(pi) - min [ ∑pi∈ P̄ r(pi) + ∑pj∈ Q c(qj) ] OPTIONAL MATERIAL

Min Cut: Project Selection ∑i r(pi) - min [ ∑pi∈ P̄ r(pi) + ∑pj∈ Q c(qj) ] s p1 p2 p3 q1 q2 q3 t ∞ r(p1) r(p2) r(p3) c(q1) c(q2) c(q3) OPTIONAL MATERIAL