analysis of algorithms week 9, lecture 2 - duke universityreif/courses/alglectures/reif... · 2016....

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

Upload: others

Post on 01-Jan-2021

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Flow Algorithms

Prepared by

John Reif, Ph.D. Distinguished Professor of Computer Science

Duke University

Analysis of Algorithms Week 9, Lecture 2

Page 2: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Flow Algorithms

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

Page 3: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Readings on Flow Algorithms

•  Reading Selection: –  CLR, Chapter 26

Page 4: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Network Definition

+

digraph G (V,E)

distinguished vertices: source s V sink t V

edge capacities: c: E R

! ="""

∈$" ∈"" →&

Page 5: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Reverse Edges

R

R

E reverse of edges in E (u,v) (v,u) the reverse of edge (u,v)u v u v

=

= =

← →

Page 6: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Definition of Network Flow

R +

R

(v,u) E

flow f: (E E ) R (1) f(e) -f(e ) for all e E (2) f(e) c(e) (3) f(v,u) 0 for all v V-{s,t}

∪ →

= ∈

= ∈∑

Page 7: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Value of Flow f

•  Flow f

•  Value v V

( ) (s,v)

sum of flow from source

f f∈

=

=

s

Page 8: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Min Cut = Max Flow

•  cut

v Xu X

X, X is partition of V

where s X, t X

(X,X) ( , )f f v u∈∈

∈ ∈

=∑

s t

X X _

Page 9: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Proof that Min Cut = Max Flow

•  Lemma

•  Proof

,

(X, X) ( , ) ( , )

( , ) ( ) 0 ( ).

. . .

v X v Xu X w X

v w X

f f u v f v w

f v w value f value f

Q E D

∈ ∈∈ ∈

= =

= = − =

∑ ∑

The flow across any cut X, Xis equal to the value( ).f

Page 10: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

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

Page 11: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

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.

Page 12: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Flow f on a path

•  Flow f on path p = (e1, e2, …, ek)

e1 e2 ek

f ( e1 ) f ( ek ) f ( e2 )

Page 13: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Augmenting Flow

•  residual res(p) = Δ = min (c(e) – f (e))

e ∈ p

•  gives Augmented flow f + res(p)

t s e1 e2

ek

f ( e1 ) +Δ f ( ek ) +Δ f ( e2 +Δ

Page 14: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Flow f and Augmenting Flow in Residual Network

s

c d

b a

t

3

3 3

4 3

2

4

1

f = 0

f = 2

f = 2

f = 2

f = 2

f = 3

f = 1

f = 1

Saturated Edge

Network with Flow

s

c d

b a

t

3

2 3

2 2

2

1

1 3

1

2 1

Residual Network

Augmenting Path (s,b,d,a,c,t)

=>

Saturated Edge

Page 15: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Min Cut = Max Flow

•  min cut: cut of minimum capacity •  max flow: max (value ( f ))

f is flow

X

X

s

t

_ Cut

Page 16: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Example of Min Cut = Max Flow

Max Flow = Min Cut = 6

Edges Labeled (Capacity, Flow)

Page 17: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Ford-Fulkerson Proof of Min Cut = Max Flow

Ford - Fulkersons:Theorem: The max flow f is equal to the

min cut , .Proof: (1) If is max flow, then there can be no augmenting path from

X Xf

s to . Let vertices in , reachable from s in residual graph .

-

( ) ( , ) ( , ) ( , )

(2) Clearly, has value at most

u X u Xv X v X

t X VR

X V X

Value f f u v c u v c X X

f

∈ ∈∈ ∈

=

=

= = =∑ ∑

( , )

for any cut , .. . .

c X X

X XQ E D

Page 18: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Bounding Flow augmentations give Max Flow

•  Lemma: At most |E| flow augmentations are required to construct max flow.

Page 19: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Improving Flow by Augmenting Flow from Residue graph

Proof: Suppose * is max flow in . Let * be subgraph of with pos. flow.

0while path from to do

1find a path from to in *let min *( )

for all do *(i

i

i e p

f GG G

is t

i ip s t Gf e

e p f∈

← +

Δ =

∈ i) *( )- if *( ) 0, then delete from * odod

Note: Deletes at least on edge per step!

e f ef e e G

⎛⎜⎜⎜⎜⎜ ← Δ⎜

≤⎜⎜⎜⎜⎝

Page 20: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

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

Page 21: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

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

level (v) length of shortest path from s to v in RL contains only edges (v,u) R s.t. level (u) level (v) 1

=

= +

Page 22: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Dinic’s Flow Algorithm

•  Input: network G=(V,E) s.t. capacities ci: (E ∪ ER) → R+

•  Initialization:

for all assign ( ) 0e f e ←

Page 23: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Dinic’s Flow Algorithm (cont’d)

•  Loop:

[1] Construct level graph for by Breadth First Search[2] By augmentations, find blocking flow ' in from .[3] for all assign ( ) ( ) '( )[4] If is not in level graph,

L f

f L fe f e f e f e

t

← +

then return else go to [1]

f

Page 24: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

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'

Page 25: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Proof of Dinic’s Flow Algorithm (cont’d)

•  Claim level' (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

Page 26: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Example of Dinic’s Flow Algorithm (cont’d)

•  Network

3

s

c d

b a

t

3

3

4 3

2

4

1

Page 27: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Example of Dinic’s Flow Algorithm (cont’d)

•  1st Level Graph with Blocking Flow

s

c d

b a

t

3

3 3

4 3

2

4

1

f = 1

f = 3

f = 2

f = 1

f = 1

f = 3

f = 0

f = 1

level 1

level 2

level 3

level 0

Page 28: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Example of Dinic’s Flow Algorithm (cont’d)

•  2nd Level Graph with Blocking Flow

s

c d

b a

t

3

2

3

2 f = 1

f = 1

f = 1

f = 0

f = 1 level 1

level 2

level 3

level 0

1

level 4

Page 29: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Example of Dinic’s Flow Algorithm (cont’d)

•  3rd Level Graph with Blocking Flow

s

c

d

b a

t

2

2

2

1 f = 1

f = 1

f = 1

f = 1 f = 1

level 0

2

level 5

Page 30: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Example of Dinic’s Flow Algorithm (cont’d)

•  Final Flow s

c d

b a

t

3

3 3

4 3

2

4

f = 1

f = 3

f = 2

f = 3

f = 3

f = 3 f = 3

f = 1

1

Page 31: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Finding a Blocking Flow

•  by Karzanov •  Preflow j:

(1) Satisfies capacities’ constraints (2) May have unbalanced vertices where

u vf(u) f(u,v) 0

Δ = >∑

Page 32: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

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

Page 33: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-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))

Page 34: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

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)).

Page 35: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Finding a Blocking Flow (cont’d)

•  Wave Algorithm for Blocking Flow Initialize: with preflow that saturates every edge out of s and otherwise 0.

S t

c(e1)

c(ek)

0

0 0

0

Page 36: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

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

Page 37: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

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

Page 38: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

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.

Page 39: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Proof of O(n2) Time for Finding a Blocking Flow •  Theorem: Wave Algorithm computes a blocking

flow in O(n2) time (and hence a max flow in O(n3) time).

•  Proof (use invariants): (1) If v blocked then every path from v to t has saturated edge. (2) The preflows constructed by algorithm are blocking.

Page 40: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Proof of O(n2) 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.

Page 41: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Proof of O(n2) Time for Finding a Blocking Flow (cont’d)

•  Note: Each step blocks at least 1 vertex

•  So at most n steps flow on edge e increases and decreases at most once

•  So total time O(|V|2 + |E|) = O(|V|2) = O(n2)

Page 42: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

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.

Page 43: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

0-1 Flow Algorithms

•  Special Case:

•  Theorem (Evan and Tarjan)

0 1 Flow, if for all e E, c(e) = 1− ∈

2 13 2

2 13 2

0 1 Flow requires min (|V| ,|E| ) blocking steps ofDinic's Algorithm, so total time

O(min(|V| ,|E| )|E|log(V)).

Page 44: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Unit Flow

•  Unit Network: All capacities are integers 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|

single entering edge orsingle departing edge.!"#

( )|V| 1( )value f≤ +

Page 45: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Illustration of Unit Flow

s t

level

G is decomposed into value(f ) vertex-disjoint paths from s to t.

Page 46: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Unit Flow Algorithms

Page 47: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

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.

Page 48: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Illustration of s-t Vertex Separator S

Page 49: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Solving Vertex Connectivity via Flow

•  Transform Vertex Connectivity to Unit Network Flow Problem

Page 50: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

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.

Page 51: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Vertex Connectivity

•  N(u,v) = min vertex cut size for (G, u, v)

•  G undirected

u,v V

(u,v) E

Vertex Connectivity: c(G)

n-1 if G is complete graphMin N(u,v) else

c(G)∈

⎧⎪⎪

= ⎨⎪⎪⎩

Page 52: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Bounding Vertex Connectivity

•  Lemma

•  Proof

•  Q.E.D. (also true for edge connectivity)

2|E|c(G) |V|≤

v V

v V

Connectivity min degree v,

but degree (v) 2|E|

2|E|Hence, c(G) |V|

=

Page 53: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Algorithm for Vertex Connectivity

•  Lemma:

•  Proof: G – S has at least 2 - components

( , )

If is ( , ) Vertex Separatorwith | | ( ), then( ) min ( , ) for all -

a b E

S u vS c G

c G N a b a V S∉

=

= ∈

Page 54: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

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.

Page 55: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Idea for Randomized Algorithm for Vertex Connectivity

•  Idea: Choose at random a ∈ V.

Time Cost O(log( 1ε)|V

32 ||E| log|E|)

Page 56: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Randomized Algorithm for Vertex Connectivity

•  (Melhorn & Students)

1

|V|

i

ib V

Input: G (V,E), error bound, , o 1 [0] |V| - 2

log ( ) [1] for i=1,2,... until ilog( )

do select a V at random min ( , min N(a , b))

od [

ε

µ

ε ε

µ

µ µ∈

= < <

2] output µ

Page 57: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Randomized Algorithm for Vertex Connectivity (cont’d)

•  Theorem: Prob (µ ≠ c(G)) ≤ ε •  Proof: Let S be a Vertex Separator with

( ) ( ) 1

1 2 k

1| |

( )

1 k

kk-log ( ) log c(G)|S|

|V| |V|

| | ( ). If c(G), then a , a ,...,aall belong to S, where

log ( )k log( )Hence, prob ( ( )) prob (a ,..., a S)

2 2 .

Vc G

S c G

c G

ε

ε

ε

µ

µ

ε

= >

> = ∈

= = = = =

Page 58: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Definition of Planar Graph

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

Page 59: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Dual of Planar Graph

•  Dual: D(G)=(F, D(E)) F = faces of embedding

D(E) = { {Fi, Fj}| e ∈ E is between Fi, Fj }

Page 60: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Max Flow in Planar Graph

Page 61: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

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

Page 62: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Definition of Outerplanar Embedded Graph

•  G is outerplanar embedded if the planar embedding has face F0 incident to all vertices.

Page 63: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Algorithm for Max Flow in Outerplanar Embedded Graph

•  Idea: To reduce to Min Cost Path

Add new edge (s,t) with weight ∞.

Page 64: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Time Cost of Algorithm for Max Flow in Outerplanar Embedded Graph

Page 65: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

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).

Page 66: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

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

Page 67: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

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.

Page 68: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

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|log2|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.

Page 69: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

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

Page 70: Analysis of Algorithms Week 9, Lecture 2 - Duke Universityreif/courses/alglectures/reif... · 2016. 11. 1. · Analysis of Algorithms Week 9, Lecture 2 . Flow Algorithms a) Max-flow,

Flow Algorithms

Prepared by

John Reif, Ph.D. Distinguished Professor of Computer Science

Duke University

Analysis of Algorithms Week 9, Lecture 2