Flow Algorithms Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms Week 9, Lecture 2.

Slides:



Advertisements
Similar presentations
Maximum flow Main goals of the lecture:
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.
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.
1 Review of some graph algorithms Graph G(V,E) (Chapter 22) –Directed, undirected –Representation Adjacency-list, adjacency-matrix Breadth-first search.
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)
The Maximum Network Flow Problem. CSE Network Flows.
Advanced Algorithm Design and Analysis (Lecture 8) SW5 fall 2004 Simonas Šaltenis E1-215b
Lectures on Network Flows
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 14 Strongly connected components Definition and motivation Algorithm Chapter 22.5.
1 Efficient implementation of Dinic’s algorithm for maximum flow.
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.
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
Graph Colouring Lecture 20: Nov 25.
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.
1 Maximum flow: The preflow/push method of Goldberg and Tarjan (87)
Data Structures, Spring 2006 © L. Joskowicz 1 Data Structures – LECTURE 14 Strongly connected components Definition and motivation Algorithm Chapter 22.5.
1 Efficient implementation of Dinic’s algorithm for maximum flow.
Maximum flow Algorithms and Networks. A&N: Maximum flow2 Today Maximum flow problem Variants Applications Briefly: Ford-Fulkerson; min cut max flow theorem.
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.
Graph Algorithms Using Depth First Search Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms.
Graph Theory Chapter 6 Planar Graphs Ch. 6. Planar Graphs.
CS774. Markov Random Field : Theory and Application Lecture 13 Kyomin Jung KAIST Oct
CS 473Lecture ?1 CS473-Algorithms I Lecture ? Network Flows Finding Max Flow.
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.
Graph Colouring Lecture 20: Nov 25. This Lecture Graph coloring is another important problem in graph theory. It also has many applications, including.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
CSEP 521 Applied Algorithms Richard Anderson Lecture 8 Network Flow.
Great Theoretical Ideas in Computer Science for Some.
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:
Maximum Flow Problem Definitions and notations The Ford-Fulkerson method.
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Graph Algorithms Minimum Spanning Tree (Chap 23)
CS4234 Optimiz(s)ation Algorithms
Lectures on Network Flows
Algorithms and Networks Hans Bodlaender
Richard Anderson Lecture 23 Network Flow
Algorithms and Networks
Graph Algorithms Using Depth First Search
Network Flow 2016/04/12.
Instructor: Shengyu Zhang
Edmonds-Karp Algorithm
Efficient implementation of Dinic’s algorithm for maximum flow
Lecture 10 Network flow Max-flow and Min-cut Ford-Fulkerson method
CS 583 Analysis of Algorithms
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 21 Network Flow
Flow Networks and Bipartite Matching
Algorithms (2IL15) – Lecture 7
EE5900 Advanced Embedded System For Smart Infrastructure
Algorithms and Networks
Lecture 21 Network Flow, Part 1
Richard Anderson Lecture 22 Network Flow
Lecture 21 Network Flow, Part 1
Maximum flow: The preflow/push method of Goldberg and Tarjan (87)
Lecture 22 Network Flow, Part 2
Richard Anderson Lecture 22 Network Flow
Advanced Graph Homer Lee 2013/10/31.
Presentation transcript:

Flow Algorithms Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms Week 9, Lecture 2

Flow Algorithms a)Max-flow, min-cut Theorem b)Augmenting Paths c)O-1 flow d)Vertex Connectivity e)Planar Flow

Readings on Flow Algorithms Reading Selection: –CLR, Chapter 26

Network Definition

Reverse Edges

Definition of Network Flow

Value of Flow f Flow f Value

Min Cut = Max Flow cut s t X X _

Proof that Min Cut = Max Flow Lemma Proof

Residual Flow and Augmenting paths residual capacity of edge e: res(e) = c(e) – f (e) residual graph R: use modified capacities c ( e)=res(e) for res(e) > 0 augmenting path p for flow f is path in R from s to t res(p) = min (res(e)) e  p

Characterization of Residual Flow Lemma: R has max flow value value ( f *) – value ( f ), where f * is the max flow of G. Proof: If f is flow in R, then f + f is flow of G. Also, f = f * – f is a flow in R. Q.E.D.

Flow f on a path Flow f on path p = (e 1, e 2, …, e k ) e1e1 e2e2 ekek f ( e 1 ) f ( e k ) f ( e 2 )

Augmenting Flow residual res(p) =  = min (c(e) – f (e)) e  p gives Augmented flow f + res(p) ts e1e1 e2e2 ekek f ( e 1 ) +  f ( e k ) +  f ( e 2 ) + 

Flow f and Augmenting Flow in Residual Network s cd ba t f = 0 f = 2 f = 3 f = 1 Saturated Edge Network with Flow s cd ba t Residual Network Augmenting Path (s,b,d,a,c,t)  Saturated Edge

Min Cut = Max Flow min cut: cut of minimum capacity max flow: max (value ( f )) f is flow X X s t _ Cut

Example of Min Cut = Max Flow Max Flow = Min Cut = 6 Edges Labeled (Capacity, Flow)

Ford-Fulkerson Proof of Min Cut = Max Flow

Bounding Flow augmentations give Max Flow Lemma: At most |E| flow augmentations are required to construct max flow.

Improving Flow by Augmenting Flow from Residue graph

Blocking Flow Definitions given flow f saturated edge e has f(e)=c(e) blocking flow f : every path from s to t has saturated edge (so cannot augment flow!) Idea: Re-route flow if it is blocking

Shortest Augmenting paths via level Graph Level Graph L is subgraph of residual graph R Note L gives shortest augmenting paths Construct L in O(|V|+|E|) time by Breadth First Search of R

Dinic’s Flow Algorithm Input: network G=(V,E) s.t. capacities c i : (E  E R )  R + Initialization:

Dinic’s Flow Algorithm (cont’d) Loop:

Proof of Dinic’s Flow Algorithm (cont’d) Theorem Dinic’s Algorithm halts after |V| blocking steps Proof Suppose f is flow with R = residual graph (currently) level (v) = min length path from s to v in R R' = new residual graph level ' (v) = min length of path s to v in R'

Proof of Dinic’s Flow Algorithm (cont’d) Claimlevel ' (t) > level (t) Proof(by contradiction) –If level (t) = level ' (t), –then level (w) = level (v)+1 for every edge –(v,w)  L. –This contradicts the fact that at least one edge is saturated (on the blocking flow) on any path p in L. Q.E.D. Hence n steps suffice for the algorithm

Example of Dinic’s Flow Algorithm (cont’d) Network 3 s cd ba t

Example of Dinic’s Flow Algorithm (cont’d) 1st Level Graph with Blocking Flow s cd ba t f = 1 f = 3 f = 2 f = 1 f = 3 f = 0 f = 1 level 1 level 2 level 3 level 0

Example of Dinic’s Flow Algorithm (cont’d) 2nd Level Graph with Blocking Flow s c d ba t f = 1 f = 0 f = 1 level 1 level 2 level 3 level 0 1 level 4

Example of Dinic’s Flow Algorithm (cont’d) 3rd Level Graph with Blocking Flow s c d b a t f = 1 level 0 2 level 5

Example of Dinic’s Flow Algorithm (cont’d) Final Flow s cd ba t f = 1 f = 3 f = 2 f = 3 f = 1 1

Finding a Blocking Flow by Karzanov Preflow j: (1) Satisfies capacities’ constraints (2) May have unbalanced vertices where

Finding a Blocking Flow (cont’d) Wave method: –begin with blocking preflow f (saturates on edge on every path s to t ) –balance vertices so  f(v) = 0 to get blocking flow

Finding a Blocking Flow (cont’d) To balance blocked vertex v: Repeat (until  f(v) = 0) do choose edge (u,v) with f(u,v) > 0 decrease f(u,v) by min (f(uv),  f(v))

Finding a Blocking Flow (cont’d) To attempt to balance unblocked vertex v : Repeat (until  f ( v ) = 0, or there is not an unsaturated edge ( v,w ) where w is unblocked). do choose some such edge ( v,w ) and decrease f ( v,w ) by min ( C ( v,w )- f ( v,w ),  f ( v )).

Finding a Blocking Flow (cont’d) Wave Algorithm for Blocking Flow Initialize: with preflow that saturates every edge out of s and otherwise 0. St c(e 1 ) c(e k ) …

Example of Finding a Blocking Flow (cont’d) Edges Labeled (Capacity, Flow) Increased Flow to Blocked vertex d Decreased Flow Balanced at vertex d But Blocked vertex c

Example of Finding a Blocking Flow (cont’d) Edges Labeled (Capacity, Flow) Decreased Flow All vertices Balanced Decreased Flow Balanced vertex c But Blocked vertex a

Finding a Blocking Flow (cont’d) Set s blocked, and set V-{s} all unblocked. Repeat until there are no unbalanced vertices do Increase flow: Scan all vertices between t,s in topological order, balancing every vertex v that is unbalanced and unblocked. (If balancing fails, make v blocked.) Decrease flow: Scan vertices in reverse topological order, balancing each vertex that is unbalanced and blocked.

Proof of O (n 2 ) Time for Finding a Blocking Flow Theorem: Wave Algorithm computes a blocking flow in O(n 2 ) time (and hence a max flow in O(n 3 ) time). Proof (use invariants): (1) If v blocked  every path from v to t has saturated edge. (2) The preflows constructed by algorithm are blocking.

Proof of O (n 2 ) Time for Finding a Blocking Flow (cont’d) Modify: s blocked, and departing edges saturated. Inductive Step: (a) Scanning in topological order in increase flow guarantees no unblocked, unbalanced vertices. (b) Scanning in reverse topological order guarantees every blocked vertex gets balanced.

Proof of O (n 2 ) Time for Finding a Blocking Flow (cont’d) Note: Each step blocks at least 1 vertex  at most n steps flow on edge e increases and decreases at most once  total time O(|V| 2 + |E|) = O(|V| 2 ) = O (n 2 )

Improved Flow Algorithms Can use data structures to decrease blocking flow algorithms to O(|E| log|V|) time, giving… Theorem Max flow can be computed in O(|V||E| log|V|) time.

0-1 Flow Algorithms Special Case: Theorem (Evan and Tarjan)

Unit Flow Unit Network: All capacities  Z and every vertex v other than s or t has Claim: If Unit Network G has max flow f, then max level is Proof: G can be decomposed into value(f ) vertex-disjoint paths from s to t. so value (f ) (level-1)  |V|

Illustration of Unit Flow st level G is decomposed into value(f ) vertex-disjoint paths from s to t.

Unit Flow Algorithms

s-t Vertex Separator s-t Vertex Separator S  V : if all paths from s to t contain v  S. Menger’s Theorem: The size of the smallest s,t Vertex Separator S is exactly the same as the number of vertex disjoint paths from s to t.

Illustration of s-t Vertex Separator S

Solving Vertex Connectivity via Flow Transform Vertex Connectivity to Unit Network Flow Problem

Time for Solving Vertex Connectivity via Flow Total Time O(|V|  |E| log(E)) to compute s-t Vertex Connectivity N ( s,t ) (from s to t ). N(s,t) = number of disjoint paths from s to t.

Vertex Connectivity N(u,v) = min vertex cut size for (G, u, v) G undirected

Bounding Vertex Connectivity Lemma Proof Q.E.D. (also true for edge connectivity)

Algorithm for Vertex Connectivity Lemma: Proof: G – S has at least 2 - components

Proof of Algorithm for Vertex Connectivity Let b be any node in a component of G-S which does not have a. Thus, N(a,b)  | S | = c(G). Q.E.D.

Idea for Randomized Algorithm for Vertex Connectivity Idea: Choose at random a  V.

Randomized Algorithm for Vertex Connectivity (Melhorn & Students)

Randomized Algorithm for Vertex Connectivity (cont’d) Theorem: Prob ( μ  c ( G ))  ε Proof: Let S be a Vertex Separator with

Definition of Planar Graph G = (V,E) is a planar graph if G can be embedded on plane so no two edges cross.

Dual of Planar Graph Dual: D(G)=(F, D(E)) F = faces of embedding D(E) = { {F i, F j }| e  E is between F i, F j }

Max Flow in Planar Graph

Min Cost Cycle in Dual Graph D(G) separating s, t

Definition of Outerplanar Embedded Graph G is outerplanar embedded if the planar embedding has face F 0 incident to all vertices.

Algorithm for Max Flow in Outerplanar Embedded Graph Idea: To reduce to Min Cost Path Add new edge (s,t) with weight .

Time Cost of Algorithm for Max Flow in Outerplanar Embedded Graph

Developing an Efficient Algorithm for Max Flow in a General Planar Graph Lemma: [Reif] If μ (s,t) is a minimum cost path in D(G) from a face bounding on s to a face bounding on t, then any min cost cycle in D(G) separating s,t must contain an edge of μ (s,t).

Illustration of μ (s,t) Path Separating s and t in Dual Graph D(G)

Proof of Lemma Proof: Suppose not. Then we can shortcut any cycle of D(G) separating s,t to get a shorter one, using edges of the μ (s,t) path.

Efficient Divide and Conquer Algorithm for Max Flow in a General Planar Graph Theorem: [Reif] The min cost flow in a planar graph can be computed in O(|V|log 2 |V|) time. Proof: Idea: use μ (s,t) cut in D(G) to guide a recursive divided and conquer algorithm. On each step, divide the μ (s,t) path in half and solve the problem on each half, separately, using s,t cut as separator.

Illustration of an Efficient Divide and Conquer Algorithm for Max Flow in a General Planar Graph

Flow Algorithms Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms Week 9, Lecture 2