Lectures on Network Flows

Slides:



Advertisements
Similar presentations
Lectures on Graph Algorithms: searching, testing and sorting
Advertisements

Lecture 7. Network Flows We consider a network with directed edges. Every edge has a capacity. If there is an edge from i to j, there is an edge from.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
1 Maximum flow sender receiver Capacity constraint Lecture 6: Jan 25.
Bioinformatics III1 We will present an algorithm that originated by Ford and Fulkerson (1962). Idea: increase the flow in a network iteratively until it.
MAX FLOW APPLICATIONS CS302, Spring 2013 David Kauchak.
Piyush Kumar (Lecture 6: MaxFlow MinCut Applications)
Introduction To Algorithms CS 445 Discussion Session 8 Instructor: Dr Alon Efrat TA : Pooja Vaswani 04/04/2005.
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 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.
Maurizio Patrignani seminar on the paper on the single-source unsplittable flow problem authored by Yefim Dinitz Naveen Garg Michel X. Goemans FOCS ‘98.
Advanced Algorithm Design and Analysis (Lecture 8) SW5 fall 2004 Simonas Šaltenis E1-215b
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Chapter 7 Maximum Flows: Polynomial Algorithms
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2001 Lecture 4 Tuesday, 2/19/02 Graph Algorithms: Part 2 Network.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 4 Tuesday, 10/2/01 Graph Algorithms: Part 2 Network.
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.
Lecture 11. Matching A set of edges which do not share a vertex is a matching. Application: Wireless Networks may consist of nodes with single radios,
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.
Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.
CS774. Markov Random Field : Theory and Application Lecture 13 Kyomin Jung KAIST Oct
1 COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf.
CS 473Lecture ?1 CS473-Algorithms I Lecture ? Network Flows Finding Max Flow.
Lectures on Greedy Algorithms and Dynamic Programming
MAX FLOW APPLICATIONS CS302, Spring 2012 David Kauchak.
Flow Algorithms Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms Week 9, Lecture 2.
CS223 Advanced Data Structures and Algorithms 1 Maximum Flow Neil Tang 3/30/2010.
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.
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.
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.
CSCI 256 Data Structures and Algorithm Analysis Lecture 20 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.
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.
Prof. Swarat Chaudhuri COMP 382: Reasoning about Algorithms Fall 2015.
Theory of Computing Lecture 12 MAS 714 Hartmut Klauck.
1 CPSC 320: Intermediate Algorithm Design and Analysis July 14, 2014.
Iterative Improvement for Domain-Specific Problems Lecturer: Jing Liu Homepage:
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
CS4234 Optimiz(s)ation Algorithms
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
Greedy Algorithms / Minimum Spanning Tree Yin Tat Lee
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
Lectures on Graph Algorithms: searching, testing and sorting
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 21 Network Flow
Max Flow Min Cut, Bipartite Matching Yin Tat Lee
Algorithms (2IL15) – Lecture 7
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
Lecture 21 Network Flow, Part 1
Richard Anderson Lecture 22 Network Flow
Lecture 21 Network Flow, Part 1
Lecture 22 Network Flow, Part 2
Presentation transcript:

Lectures on Network Flows COMP 523: Advanced Algorithmic Techniques Lecturer: Dariusz Kowalski Lectures on Network Flows

Lectures on Network Flows Overview Previous lectures: Dynamic programming Weighted interval scheduling Sequence alignment These lectures: Network flows Applications: largest matching in bipartite graphs Lectures on Network Flows

Lectures on Network Flows A directed graph G = (V,E) such that each directed edge e has its nonnegative capacity denoted by ce there is a node s (source) with no incoming edges there is a node t (target) with no outgoing edges u 20 10 u,v - internal nodes 30 t s 10 20 v Lectures on Network Flows

20 t s 10 u v 30

Lectures on Network Flows s-t flow in G = (V,E) is a function f from E to R+ capacity condition: for each e, 0  f(e)  ce conservation condition: for each internal node v, ∑e in v f(e) = ∑e out v f(e) there is a node t (target) with no outgoing edges Property: ∑e in t f(e) = ∑e out s f(e) u u Network: 20 10 Flow: 20 10 30 t 10 t s s 10 20 10 20 Lectures on Network Flows v v

20 t s 10 u v 30 Network: 20 t s 10 u v Flow:

Lectures on Network Flows Useful definitions Given s-t flow f in G = (V,E) and any subset of nodes S f in(S) = ∑e in S f(e) f out(S) = ∑e out S f(e) Property: f in(t) = f out(s) Example: f in(u,v) = f out(u,v) = 30 u u Network: 20 10 Flow: 20 10 30 t s 10 t s 10 20 10 20 Lectures on Network Flows v v

Lectures on Network Flows Problem(s) What is the maximum value of f in(t) (flow) for a given graph G = (V,E) ? How to compute it efficiently? Assumption: capacities are positive integers. Example: f in(t) = f out(s) = 30 u u Network: 20 10 Flow: 20 10 30 t s 10 t s 10 20 10 20 Lectures on Network Flows v v

Lectures on Network Flows Residual graph Assume that we are given a flow f in graph G. Residual graph Gf The same nodes, internal and s,t For each edge e in E with ce > f(e) we put weight ce - f(e) (residual capacity) For each edge e = (u,v) in E we put weight f(e) to the backward edge (v,u) (residual capacity) u Network: u Residual Graph: 20 u Flow: 20 10 20 10 20 t s 30 t 20 10 t s s 20 10 20 10 20 v Lectures on Network Flows v v

Augmenting path & augmentation Assume that we are given a flow f in graph G, and the corresponding residual graph Gf Find a new flow in residual graph - through a path with no repeating nodes, and value equal to the minimum capacity on the path (augmenting path) Update residual graph along the path New residual graph: u New flow: Network: u 10 20 u 20 10 10 10 20 10 t 20 s 30 t 10 10 20 t s 20 s v 10 10 20 20 Lectures on Network Flows v v

u 20 t s 10 v Residual Graph: u 20 t s v Flow: 20 t s 10 v New residual graph: u New flow: 20 t s 10 v u

Ford-Fulkerson Algorithm Initialize f(e) = 0 for all e While there is s-t path P in residual graph Augment f through path P and get new f and new residual graph Augment f through path P : Find minimum capacity on the path Go through the path and modify weights u Network: New flow: u New residual graph: u 20 10 10 10 20 20 30 t 10 20 10 10 20 t s s t s 10 10 10 20 20 20 v v v Lectures on Network Flows

Lectures on Network Flows Analysis Correctness: maximum flow - proof later termination - each time the flow is an integer and advances by at least 1 (assumption about integer capacities) Time: O(mC) at most C iterations, where C is the value of the maximum flow, m is the number of edges each iteration takes O(m+n) steps - use DFS to find path P u Network: New flow: u New residual graph: u 20 10 10 10 20 20 30 t 10 20 10 10 20 t s s t s 10 10 10 20 20 20 v v v Lectures on Network Flows

Reminder: Depth-First Search (DFS) Given a directed graph G = (V,E) of diameter D and the root node Goal: find a directed rooted spanning tree such that each edge in graph G corresponds to the ancestor relation in the tree Recursive idea of the algorithm: Repeat until no neighbor of the root is free Select a free out-neighbor v of the root and add the edge from root to v to partial DFS Recursively find a DFS’ in graph G restricted to free nodes and node v as the root’ and add it to partial DFS root’ root root’’ Lectures on Network Flows

Lectures on Network Flows Implementing DFS Structures: Adjacency list List (stack) S Array Discovered[1…n] Algorithm: Set S = {root} Consider the top element v in S For each out-neighbor w of node v, if w is not Discovered then put w into the stack S and start the next iteration for w as the top element Otherwise remove v from the stack, add edge (z,v) to partial DFS, where z is the current top element, and start the next iteration for z as the top element Remark: after considering the out-neighbor of node v we remove this neighbor from adjacency list to avoid considering it many times! root’ root root’’ Lectures on Network Flows

Lectures on Network Flows Flows vs. Cuts (A,B) - cut in graph G: A,B is a partition of nodes, s in A, t in B c(A,B) = ∑e out A c(e) = ∑e in B c(e) is the capacity of this cut Property: Minimum cut is equal to the maximum flow Example: c(A,B) = 50 u u A 20 10 20 10 B 30 t 30 t s s 10 20 10 20 v v Lectures on Network Flows

Lectures on Network Flows Max Flow vs. Min Cut For any set A containing s we proceed in 3 steps: value(f) = ∑v in A ∑e out v f(e) - ∑v in A ∑e in v f(e) value(f) = f out(A) - f in(A) c(A,B)  f out(A) - f in(A) = value(f) Conclusion: Min-cut  value(f) Example: c(A,B) = 50 and f out(A) = 30 u u A 20 10 20 10/10 B 30 t 30/10 t s s 10 20 10/10 20 v v Lectures on Network Flows

FF-algorithm gives Max-flow Suppose FF-algorithm stopped with flow f : Directed DFS tree rooted in s does not contain t It means that cut-capacity between nodes in DFS and the remaining ones is 0 in residual graph It follows that each edge in this cut has been reversed by augmenting flow, which means that c(DFS,DFS’) = value(f) Using Min-cut  value(f) we get that f is maximum u u 20 10 Residual graph: 20 10 30 t 10 20 t s s DFS 10 20 10 20 Lectures on Network Flows v Min-cut v

Lectures on Network Flows Conclusions Network flow algorithms: Ford-Fulkerson algorithm in time O(mC) Correspondence between max-flows and min-cuts Lectures on Network Flows

Lectures on Network Flows Exercises READING: Chapter 7, Sections 7.1, 7.2, and 7.3 EXERCISES: Modify FF-algorithm to work in time O(m2 log C) Find an augmentation scheme to guarantee time O(mn) in FF-algorithm independently from integer C Lectures on Network Flows

Lectures on Network Flows Overview Previous lecture: Network flows Ford-Fulkerson algorithm Max-flows versus Min-cuts This lecture: Rational and real capacities in network Applications: largest matching in bipartite graphs Application to disjoint paths problem Lectures on Network Flows

Lectures on Network Flows Given a directed graph G = (V,E) such that each directed edge e has its nonnegative capacity denoted by ce there is a node s (source) with no incoming edges there is a node t (target) with no outgoing edges u 20 10 u,v - internal nodes 30 t s 10 20 v Lectures on Network Flows

Lectures on Network Flows s-t flow in G = (V,E) is a function f from E to R+ capacity condition: for each e, 0  f(e)  ce conservation condition: for each internal node v, ∑e in v f(e) = ∑e out v f(e) there is a node t (target) with no outgoing edges Property: ∑e in t f(e) = ∑e out s f(e) u u Network: 20 10 Flow: 20 10 30 t 10 t s s 10 20 10 20 Lectures on Network Flows v v

Lectures on Network Flows Problem What is a maximum value f in(t) = f out(s) (flow) for a given graph G = (V,E) ? How to compute it efficiently? Assumption: capacities are positive integers. Example: f in(t) = f out(s) = 30 u u Network: 20 10 Flow: 20 10 30 t s 10 t s 10 20 10 20 Lectures on Network Flows v v

Ford-Fulkerson Algorithm Initialize f(e) = 0 for all e While there is s-t path P in residual graph Augment f through path P and get new f and new residual graph Augment f through path P : Find minimum capacity on the path Go through the path and modify weights u Network: New flow: u New residual graph: u 20 10 10 10 20 20 30 t 10 20 10 10 20 t s s t s 10 10 10 20 20 20 v v v Lectures on Network Flows

Non-integer capacities Rational capacities - rescale them to integers by multiplying by the common multiply Real capacities - difficult to handle: Min-cut = Max-flow FF-algorithm may work very slowly u New flow: u New residual graph: u Graph: 10 10 10 20 20 20 t 30 t 10 20 10 10 20 s s t s 10 10 10 20 20 20 v v v Lectures on Network Flows

Lectures on Network Flows Flows vs. Cuts (A,B) - cut in graph G: A,B is a partition of nodes, s in A, t in B c(A,B) = ∑e out A c(e) = ∑e in B c(e) is a capacity of the cut Property: Minimum cut is equal to the maximum flow Example: c(A,B) = 50 u u A 20 10 20 10 B 30 t 30 t s s 10 20 10 20 v v Lectures on Network Flows

Applications - largest matching Input: bipartite graph G=(V,W,E) Goal: largest set of non-incident edges (with different ends) Solution using flow algorithms: Lets direct edges from V to W, introduce s connected to all nodes in V, t connected from all nodes in W Capacities are 1 for all edges Max-flow is the largest matching t s Lectures on Network Flows

t s

Applications - disjoint paths Input: network graph G=(V,E) Goal: largest set of edge-disjoint paths from s to t Solution: Using flow algorithms, where each edge has capacity 1 t s Lectures on Network Flows

Lectures on Network Flows Disjoint paths cont. Suppose that k is the largest number of edge-disjoint paths from s to t. It is also a flow: capacity condition is clear since we push flow with value 1 through each path, and conservation is satisfied since if a path comes into a node it also goes out Conclusion: the largest number of edge-disjoint paths from s to t is not bigger than Max-flow t s Lectures on Network Flows

Lectures on Network Flows Disjoint paths cont. Suppose that x is the value of Max-flow produced by FF-algorithm. How to construct x edge-disjoint paths from s to t ? By induction on the number of edges in the flow. For 0 edges trivial (nothing to do, no even a path) Assume j edges in the flow. Take one of them (s,v) and continue going using edges in the flow: We go to t - done, since we have path, remove it from the graph and continue by induction We make a cycle - reduce the flow along the cycle to zero, and the obtained is a flow having the same value but smaller number of edges - next continue by induction t s Lectures on Network Flows

Lectures on Network Flows Complexity Time of FF-algorithm: O(mn) ( since C = O(n) ) Time of extracting paths: each edge is considered once while extracting one path, hence total time O(mn) Total time: O(mn) Additional memory: O(m+n) for keeping paths t s Lectures on Network Flows

Lectures on Network Flows Conclusions Network flow algorithms: Rational capacities are easy to deal with Real capacities are difficult to compute - although we can alternatively check Min-cut Application to the largest matching problem in time O(mn) (n = C since capacities are 1) Application to the edge-disjoint paths problem in time O(mn) (n = C since capacities are 1) Lectures on Network Flows

Textbook and Exercises READING: Chapter 7, Sections 7.5, 7.6 and 7.7 EXERCISES: Find a network with real capacities for which FF-algorithm works very slowly Prove formally that FF-algorithm gives the largest matching in the last application Design the algorithm for finding the largest number of edge-disjoint paths from s to t in undirected network Design the algorithm for finding the largest number of node-disjoint paths from s to t in both directed and undirected networks Lectures on Network Flows