1 Efficient implementation of Dinic’s algorithm for maximum flow.

Slides:



Advertisements
Similar presentations
Min Cost Flow: Polynomial Algorithms. Overview Recap: Min Cost Flow, Residual Network Potential and Reduced Cost Polynomial Algorithms Approach Capacity.
Advertisements

1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
EMIS 8374 Vertex Connectivity Updated 20 March 2008.
Breadth-First Search of Graphs Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms.
Max Flow: Shortest Augmenting Path
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)
CSE 326: Data Structures Network Flow and APSP Ben Lerner Summer 2007.
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Advanced Algorithm Design and Analysis (Lecture 8) SW5 fall 2004 Simonas Šaltenis E1-215b
Lectures on Network Flows
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.
Nick McKeown Spring 2012 Maximum Matching Algorithms EE384x Packet Switch Architectures.
1 Efficient implementation of Dinic’s algorithm for maximum flow.
CS138A Network Flows Peter Schröder. CS138A Flow Networks Definitions a flow network G=(V,E) is a directed graph in which each edge (u,v)
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2001 Lecture 4 Tuesday, 2/19/02 Graph Algorithms: Part 2 Network.
A New Approach to the Maximum-Flow Problem Andrew V. Goldberg, Robert E. Tarjan Presented by Andrew Guillory.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 4 Tuesday, 10/2/01 Graph Algorithms: Part 2 Network.
Flows sourcesink s t Flows sourcesink edge-weights = capacities.
1 Maximum flow: The preflow/push method of Goldberg and Tarjan (87)
Maximum flow Algorithms and Networks. A&N: Maximum flow2 Today Maximum flow problem Variants Applications Briefly: Ford-Fulkerson; min cut max flow theorem.
3/3/ Alperovich Alexander. Motivation  Find a maximal flow over a directed graph  Source and sink vertices are given 3/3/
A New Approach to the Maximum-Flow Problem Andrew V. Goldberg, Robert E. Tarjan Presented by Andrew Guillory.
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.
Assignment 4. (Due on Dec 2. 2:30 p.m.) This time, Prof. Yao and I can explain the questions, but we will NOT tell you how to solve the problems. Question.
Theory of Computing Lecture 13 MAS 714 Hartmut Klauck.
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.
Flow Algorithms Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms Week 9, Lecture 2.
1 WEEK 11 Graphs III Network Flow Problems A Simple Maximum-Flow Algorithm Izmir University of Economics.
CS 473Lecture ?1 CS473-Algorithms I Lecture ? Network Flows Flow Networks & Flows.
Chapter 7 April 28 Network Flow.
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.
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.
Outline Standard 2-way minimum graph cut problem. Applications to problems in computer vision Classical algorithms from the theory literature A new algorithm.
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,
Maximum Flow Problem Definitions and notations The Ford-Fulkerson method.
Instructor Neelima Gupta Edited by Divya Gaur(39, MCS '09) Thanks to: Bhavya(9), Deepika(10), Deepika Bisht(11) (MCS '09)
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Submodularity Reading Group Minimum Cut, Dinic’s Algorithm
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Lectures on Network Flows
Algorithms and Networks Hans Bodlaender
Edmunds-Karp Algorithm: Choosing Good Augmenting Paths
Maximum flow: The preflow/push method of Goldberg and Tarjan (87)
Edmonds-Karp Algorithm
Efficient implementation of Dinic’s algorithm for maximum 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
Lecture 10 Network flow Max-flow and Min-cut Ford-Fulkerson method
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 21 Network Flow
Algorithms (2IL15) – Lecture 7
EE5900 Advanced Embedded System For Smart Infrastructure
and 6.855J March 6, 2003 Maximum Flows 2
Network Flow.
Lecture 21 Network Flow, Part 1
Richard Anderson Lecture 22 Network Flow
Maximum flow: The preflow/push method of Goldberg and Tarjan (87)
Lecture 22 Network Flow, Part 2
Network Flow.
Advanced Graph Homer Lee 2013/10/31.
Presentation transcript:

1 Efficient implementation of Dinic’s algorithm for maximum flow

2 Goal An algorithm that finds a maximum flow from s to t in a directed graph in O(mnlog(n)) time.

3 Definitions G=(V,E) is a directed graph capacity c(v,w) for every v,w  V: If (v,w)  E then c(v,w) = 0 Two distinguished vertices s and t. s t ab cd

4 Definitions (cont) A flow is a function on the edges which satisfies the following requirements f(v,w) = -f(w,v) skew symmetry f(v,w)  c(v,w) For every v except s and t  w f(v,w) = 0 The value of the flow |f| =  w f(s,w) The maxflow problem is to find f with maximum value

5 Flows and s-t cuts Let (X,X’) be a cut such that s  X, t  X’. s t f(X,X’) =  f(v,w) =  f(v,w) -  f(v,w) = |f| - 0 = |f| |f|  cap(X,X’) =  c(v,w) Flow is the same across any cut: so The value of the maximum flow is smaller than the minimum capacity of a cut. v  X, w  X’ v  X, w  V v  X, w  X

6 More definitions The residual capacity of a flow is a function r on the edges such that r(v,w) = c(v,w) - f(v,w) a d 2, 1 Interpretation: We can push r(v,w) more flow from v to w by increasing f(v,w) and decreasing f(w,v)

7 More definitions (cont) We define the residual graph R on V such that there is an arc from v to w with capacity r(v,w) for every v and w such that r(v,w) > 0 An augmenting path p  R is a path from s to t in R r(p) = min r(v,w) (v,w)  p We can increase the flow by r(p)

8 Example s t ab cd s t ab cd A flow The residual network

9 Basic theorem (1) f is max flow (2) There is no augmenting path in R (3) |f| = cap(X,X’) for some X Proof. (3) ==> (1), (1) ==> (2) obvious To prove (2) ==>(3) let X be all vertices reachable from s in R. By assumption t  X. So (X,X’) is an s-t cut. Since there is no edge from X to X’ in R |f| = f(X,X’) =  f(v,w) =  c(v,w) = cap(X,X’)

10 Basic Scheme Repeat the following step: Find an augmenting path in R, increase the flow, update R Stop when s and t are disconnected in R. Need to be careful about how you choose those augmenting paths !

11 Edmonds and Karp Choose a shortest augmenting path ==> O(m 2 n) time algorithm

12 Dinic Def: A flow f is blocking if every path from s to t contains a saturated edge. Note that a blocking flow need not be a maximum flow!

13 Example s t ab cd Is this a blocking flow ? 1

14 Example s t ab cd Is this a maximum flow ? 1

15 Example (cont) s t ab cd s t ab cd

16 Dinic’s algorithm Let level(v) be the length of the shortest path from s to v in R. Let L be the subgraph of R containing only edges (v,w) such that level(w) = level(v) + 1 Dinic: find a blocking flow f’ in L let f := f + f’ and repeat.

17 Dinic’s algorithm (analysis) Theorem: f is a maximum flow after at most n-1 blocking flow computations. Proof. Each edge in R’ is either an edge in R or the reverse of an edge in R. Look at a shortest path from s to t in R’ s t The level in R increases by at most one at each step but cannot increase by exactly one at every step

18 Dinic’s algorithm (analysis) How fast can we find a blocking flow ? Using DFS in a straightforward manner would give us O(nm). ==> O(n 2 m) for the whole max flow algorithm. We will see how to do it in O(mlog(n)) !

19 Spend less time for each edge saturation Maintain a collection of trees (subgraph of L) where each vertex v has at most one unsaturated edge going out of v. Each edge has weight which is its current residual capacity s Start such that each vertex is in a separate tree.

20 Dinic (fast implementation) Advance: v = findroot(s), if v=t goto augment. if there is no edge going out of v goto retreat else choose an edge (v, w) going out of v and perform link(v,w,r(v,w)) goto advance Augment: (v,c) = mincost(s), addcost(s,-c), goto delete. delete: delete the edge (v, p(v)) from the graph. f(v,p(v)) = c(v,p(v)). cut(v). (v,c) = mincost(s). If (c=0) goto delete else goto advance. retreat: (All paths from v to t are blocked) if (v=s) halt. Delete every edge (u,v) from the graph. If (v  p(u)) then f(u,v) = 0. Otherwise, let (u,  ) = mincost(u), f(u,v) = c(u,v) - , cut(u). Goto advance.

21 Operations that we do on the trees Maketree(v) w = findroot(v) (v,c) = mincost(v) addcost(v,c) link(v,w,r(v,w)) cut(v)

22 How many such operations do we do? We can associate each operation that we do with an edge that is added to or deleted from the forest. Since each edge is added or deleted once from the forest we do O(m) operations on the trees. We will show how to do each such operation in O(log(n)) time So we get an O(nmlog(n)) implementation of Dinic’s algorithm.