cs 6824: network flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · cs 6824: network flow t....

132
CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Upload: others

Post on 19-Jun-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

CS 6824: Network Flow

T. M. Murali

February 12, 2014

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 2: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Maximum Flow and Minimum Cut

I Two rich algorithmic problems.

I Fundamental problems in combinatorial optimization.

I Beautiful mathematical duality between flows and cuts.

I Numerous non-trivial applications:

I Bipartite matching.

I Data mining.

I Project selection.

I Airline scheduling.

I Baseball elimination.

I Image segmentation.

I Network connectivity.

I Open-pit mining.

I Network reliability.

I Distributed computing.

I Egalitarian stable matching.

I Security of statistical data.

I Network intrusion detection.

I Multi-camera scene reconstruction.

I Gene function prediction.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 3: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

History

(Soviet Rail Network, Tolstoi, 1930; Harris and Ross, 1955; Alexander Schrijver,Math Programming, 91: 3, 2002.)

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 4: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Flow NetworksI Use directed graphs to model transporation networks:

I edges carry traffic and have capacities.I nodes act as switches.I source nodes generate traffic, sink nodes absorb traffic.

I A flow network is a directed graph G (V ,E )I Each edge e ∈ E has a capacity c(e) > 0.I There is a single source node s ∈ V .I There is a single sink node t ∈ V .I Nodes other than s and t are internal.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 5: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Flow NetworksI Use directed graphs to model transporation networks:

I edges carry traffic and have capacities.I nodes act as switches.I source nodes generate traffic, sink nodes absorb traffic.

I A flow network is a directed graph G (V ,E )I Each edge e ∈ E has a capacity c(e) > 0.I There is a single source node s ∈ V .I There is a single sink node t ∈ V .I Nodes other than s and t are internal.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 6: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Defining Flow

I In a flow network G (V ,E ), an s-t flow is a function f : E → R+ such that

(i) (Capacity conditions) For each e ∈ E , 0 ≤ f (e) ≤ c(e).(ii) (Conservation conditions) For each internal node v ,∑

e into v

f (e) =∑

e out of v

f (e)

I The value of a flow is ν(f ) =∑

e out of s f (e).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 7: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Maximum-Flow Problem

Maximum Flow

INSTANCE: A flow network G

SOLUTION: The flow with largest value in G , where the maximum istaking over all possible flows on G .

I Output should assign a flow value to each edge in the graph.

I The flow on each edge should satisfy the capacity condition.

I The flow into and out of each internal node should satisfy the conservationconditions.

I The value of the output flow, i.e., the total flow out of the source node in theoutput flow, must be the largest over all possible flows on G .

I Assumptions:

1. No edges enter s, no edges leave t.2. There is at least one edge incident on each node.3. All edge capacities are integers.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 8: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Maximum-Flow Problem

Maximum Flow

INSTANCE: A flow network G

SOLUTION: The flow with largest value in G , where the maximum istaking over all possible flows on G .

I Output should assign a flow value to each edge in the graph.

I The flow on each edge should satisfy the capacity condition.

I The flow into and out of each internal node should satisfy the conservationconditions.

I The value of the output flow, i.e., the total flow out of the source node in theoutput flow, must be the largest over all possible flows on G .

I Assumptions:

1. No edges enter s, no edges leave t.2. There is at least one edge incident on each node.3. All edge capacities are integers.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 9: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Examples of Flows

20

30

10

2010

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 10: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Examples of Flows

20

30

10

2010

0 0

0

0 0

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 11: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Examples of Flows

20

30

10

2010

10 0

10

0 10

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 12: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Examples of Flows

20

30

10

2010

10 10

0

0 0

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 13: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Examples of Flows

20

30

10

2010

10 10

10

0 10

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 14: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Examples of Flows

20

30

10

2010

20 10

10

0 10

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 15: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Examples of Flows

20

30

10

2010

20 10

10

10 20

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 16: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Developing the Algorithm

I Let us take a greedy approach.

1. Start with zero flow along all edges (Figure 7.3(a)).2. Find an s-t path and push as much flow along it as possible (Figure 7.3(b)).

3. Idea to increase flow: Push flow along edges with leftover capacity and undoflow on edges already carrying flow.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 17: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Developing the Algorithm

I Let us take a greedy approach.

1. Start with zero flow along all edges (Figure 7.3(a)).

2. Find an s-t path and push as much flow along it as possible (Figure 7.3(b)).3. Idea to increase flow: Push flow along edges with leftover capacity and undo

flow on edges already carrying flow.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 18: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Developing the Algorithm

I Let us take a greedy approach.

1. Start with zero flow along all edges (Figure 7.3(a)).2. Find an s-t path and push as much flow along it as possible (Figure 7.3(b)).

3. Idea to increase flow: Push flow along edges with leftover capacity and undoflow on edges already carrying flow.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 19: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Developing the Algorithm

I Let us take a greedy approach.

1. Start with zero flow along all edges (Figure 7.3(a)).2. Find an s-t path and push as much flow along it as possible (Figure 7.3(b)).3. Idea to increase flow: Push flow along edges with leftover capacity and undo

flow on edges already carrying flow.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 20: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Residual Graph

I Given a flow network G (V ,E ) and a flow f on G , the residual graph Gf of Gwith respect to f is a directed graph such that

(i) (Nodes) Gf has the same nodes as G .(ii) (Forward edges) For each edge e = (u, v) ∈ E such that f (e) < c(e), Gf

contains the edge (u, v) with a residual capacity c(e)− f (e).(iii) (Backward edges) For each edge e ∈ E such that f (e) > 0, Gf contains the

edge e′ = (v , u) with a residual capacity f (e).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 21: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Augmenting Paths in a Residual GraphI Let P be a simple s-t path in Gf .

I b = bottleneck(P, f ) is the minimumresidual capacity of any edge in P.

I The following operation augment(f ,P)yields a new flow f ′ in G :

I e is forward edge in Gf ⇒ flow increasesalong e in G .

I e = (u, v) is backward edge in Gf ⇒ flowdecreases along (v , u) in G .

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 22: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Augmenting Paths in a Residual GraphI Let P be a simple s-t path in Gf .

I b = bottleneck(P, f ) is the minimumresidual capacity of any edge in P.

I The following operation augment(f ,P)yields a new flow f ′ in G :

I e is forward edge in Gf ⇒ flow increasesalong e in G .

I e = (u, v) is backward edge in Gf ⇒ flowdecreases along (v , u) in G .

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 23: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of augment(f ,P)

I A simple s-t path in the residual graph is an augmenting path.I Let f ′ be the flow returned by augment(f ,P).I Claim: f ′ is a flow. Verify capacity and conservation conditions.

I Only need to check edges and internal nodes in P.I Capacity condition on e = (u, v) ∈ Gf : Note that b = bottleneck(P, f ) ≤

residual capacity of (u, v).

I e is a forward edge:0 ≤ f (e) ≤ f ′(e) = f (e) + b ≤ f (e) +

(c(e)− f (e)

)= c(e).

I e is a backward edge: c(e) ≥ f (e) ≥ f ′(e) = f (e)− b ≥ f (e)− f (e) = 0.

I Conservation condition on internal node v ∈ P.

Four cases to work out.

After augmentation

Residual graph

Forward Forward

Flow into v increases by b

Flow out of v increases by b

After augmentation

Residual graph

Backward Backward

Flow into v decreases by b

Flow out of v decreases by b

After augmentation

Residual graph

Forward Backward

Flow into v increases by b and decreases by b

Flow out of v does not change

After augmentation

Residual graph

ForwardBackward

Flow into v does not change

Flow out of v increases by b and decreases by b

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 24: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of augment(f ,P)

I A simple s-t path in the residual graph is an augmenting path.I Let f ′ be the flow returned by augment(f ,P).I Claim: f ′ is a flow. Verify capacity and conservation conditions.

I Only need to check edges and internal nodes in P.

I Capacity condition on e = (u, v) ∈ Gf : Note that b = bottleneck(P, f ) ≤residual capacity of (u, v).

I e is a forward edge:0 ≤ f (e) ≤ f ′(e) = f (e) + b ≤ f (e) +

(c(e)− f (e)

)= c(e).

I e is a backward edge: c(e) ≥ f (e) ≥ f ′(e) = f (e)− b ≥ f (e)− f (e) = 0.

I Conservation condition on internal node v ∈ P.

Four cases to work out.

After augmentation

Residual graph

Forward Forward

Flow into v increases by b

Flow out of v increases by b

After augmentation

Residual graph

Backward Backward

Flow into v decreases by b

Flow out of v decreases by b

After augmentation

Residual graph

Forward Backward

Flow into v increases by b and decreases by b

Flow out of v does not change

After augmentation

Residual graph

ForwardBackward

Flow into v does not change

Flow out of v increases by b and decreases by b

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 25: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of augment(f ,P)

I A simple s-t path in the residual graph is an augmenting path.I Let f ′ be the flow returned by augment(f ,P).I Claim: f ′ is a flow. Verify capacity and conservation conditions.

I Only need to check edges and internal nodes in P.I Capacity condition on e = (u, v) ∈ Gf : Note that b = bottleneck(P, f ) ≤

residual capacity of (u, v).

I e is a forward edge:0 ≤ f (e) ≤ f ′(e) = f (e) + b ≤ f (e) +

(c(e)− f (e)

)= c(e).

I e is a backward edge: c(e) ≥ f (e) ≥ f ′(e) = f (e)− b ≥ f (e)− f (e) = 0.I Conservation condition on internal node v ∈ P.

Four cases to work out.

After augmentation

Residual graph

Forward Forward

Flow into v increases by b

Flow out of v increases by b

After augmentation

Residual graph

Backward Backward

Flow into v decreases by b

Flow out of v decreases by b

After augmentation

Residual graph

Forward Backward

Flow into v increases by b and decreases by b

Flow out of v does not change

After augmentation

Residual graph

ForwardBackward

Flow into v does not change

Flow out of v increases by b and decreases by b

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 26: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of augment(f ,P)

I A simple s-t path in the residual graph is an augmenting path.I Let f ′ be the flow returned by augment(f ,P).I Claim: f ′ is a flow. Verify capacity and conservation conditions.

I Only need to check edges and internal nodes in P.I Capacity condition on e = (u, v) ∈ Gf : Note that b = bottleneck(P, f ) ≤

residual capacity of (u, v).I e is a forward edge:

0 ≤ f (e) ≤ f ′(e) = f (e) + b ≤ f (e) +(c(e)− f (e)

)= c(e).

I e is a backward edge: c(e) ≥ f (e) ≥ f ′(e) = f (e)− b ≥ f (e)− f (e) = 0.I Conservation condition on internal node v ∈ P.

Four cases to work out.

Before augmentation

Forward edge

After augmentation

Residual graph

After augmentation

Residual graph

Forward Forward

Flow into v increases by b

Flow out of v increases by b

After augmentation

Residual graph

Backward Backward

Flow into v decreases by b

Flow out of v decreases by b

After augmentation

Residual graph

Forward Backward

Flow into v increases by b and decreases by b

Flow out of v does not change

After augmentation

Residual graph

ForwardBackward

Flow into v does not change

Flow out of v increases by b and decreases by b

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 27: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of augment(f ,P)

I A simple s-t path in the residual graph is an augmenting path.I Let f ′ be the flow returned by augment(f ,P).I Claim: f ′ is a flow. Verify capacity and conservation conditions.

I Only need to check edges and internal nodes in P.I Capacity condition on e = (u, v) ∈ Gf : Note that b = bottleneck(P, f ) ≤

residual capacity of (u, v).I e is a forward edge:

0 ≤ f (e) ≤ f ′(e) = f (e) + b ≤ f (e) +(c(e)− f (e)

)= c(e).

I e is a backward edge: c(e) ≥ f (e) ≥ f ′(e) = f (e)− b ≥ f (e)− f (e) = 0.

I Conservation condition on internal node v ∈ P.

Four cases to work out.

Before augmentation

Forward edge

After augmentation

Residual graph

After augmentation

Residual graph

Forward Forward

Flow into v increases by b

Flow out of v increases by b

After augmentation

Residual graph

Backward Backward

Flow into v decreases by b

Flow out of v decreases by b

After augmentation

Residual graph

Forward Backward

Flow into v increases by b and decreases by b

Flow out of v does not change

After augmentation

Residual graph

ForwardBackward

Flow into v does not change

Flow out of v increases by b and decreases by b

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 28: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of augment(f ,P)

I A simple s-t path in the residual graph is an augmenting path.I Let f ′ be the flow returned by augment(f ,P).I Claim: f ′ is a flow. Verify capacity and conservation conditions.

I Only need to check edges and internal nodes in P.I Capacity condition on e = (u, v) ∈ Gf : Note that b = bottleneck(P, f ) ≤

residual capacity of (u, v).I e is a forward edge:

0 ≤ f (e) ≤ f ′(e) = f (e) + b ≤ f (e) +(c(e)− f (e)

)= c(e).

I e is a backward edge: c(e) ≥ f (e) ≥ f ′(e) = f (e)− b ≥ f (e)− f (e) = 0.I Conservation condition on internal node v ∈ P.

Four cases to work out.

After augmentation

Residual graph

Forward Forward

Flow into v increases by b

Flow out of v increases by b

After augmentation

Residual graph

Backward Backward

Flow into v decreases by b

Flow out of v decreases by b

After augmentation

Residual graph

Forward Backward

Flow into v increases by b and decreases by b

Flow out of v does not change

After augmentation

Residual graph

ForwardBackward

Flow into v does not change

Flow out of v increases by b and decreases by b

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 29: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of augment(f ,P)

I A simple s-t path in the residual graph is an augmenting path.I Let f ′ be the flow returned by augment(f ,P).I Claim: f ′ is a flow. Verify capacity and conservation conditions.

I Only need to check edges and internal nodes in P.I Capacity condition on e = (u, v) ∈ Gf : Note that b = bottleneck(P, f ) ≤

residual capacity of (u, v).I e is a forward edge:

0 ≤ f (e) ≤ f ′(e) = f (e) + b ≤ f (e) +(c(e)− f (e)

)= c(e).

I e is a backward edge: c(e) ≥ f (e) ≥ f ′(e) = f (e)− b ≥ f (e)− f (e) = 0.I Conservation condition on internal node v ∈ P. Four cases to work out.

After augmentation

Residual graph

Forward Forward

Flow into v increases by b

Flow out of v increases by b

After augmentation

Residual graph

Backward Backward

Flow into v decreases by b

Flow out of v decreases by b

After augmentation

Residual graph

Forward Backward

Flow into v increases by b and decreases by b

Flow out of v does not change

After augmentation

Residual graph

ForwardBackward

Flow into v does not change

Flow out of v increases by b and decreases by b

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 30: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Ford-Fulkerson Algorithm

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 31: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Analysis of the Ford-Fulkerson Algorithm

I Running timeI Does the algorithm terminate?I If so, how many loops does the algorithm take?

I Correctness: if the algorithm terminates, why does it output a maximumflow?

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 32: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Termination of the Ford-Fulkerson Algorithm

I Claim: at each stage, flow values and residual capacities are integers.

Proveby induction.

I Claim: Flow value strictly increases when we apply augment(f ,P).v(f ′) = v(f ) + bottleneck(P, f ) > v(f ).

I Claim: Maximum value of any flow is C =∑

e out of s c(e).

I Claim: Algorithm terminates in at most C iterations.

I Claim: Algorithm runs in O(mC ) time.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 33: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Termination of the Ford-Fulkerson Algorithm

I Claim: at each stage, flow values and residual capacities are integers. Proveby induction.

I Claim: Flow value strictly increases when we apply augment(f ,P).v(f ′) = v(f ) + bottleneck(P, f ) > v(f ).

I Claim: Maximum value of any flow is C =∑

e out of s c(e).

I Claim: Algorithm terminates in at most C iterations.

I Claim: Algorithm runs in O(mC ) time.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 34: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Termination of the Ford-Fulkerson Algorithm

I Claim: at each stage, flow values and residual capacities are integers. Proveby induction.

I Claim: Flow value strictly increases when we apply augment(f ,P).

v(f ′) = v(f ) + bottleneck(P, f ) > v(f ).

I Claim: Maximum value of any flow is C =∑

e out of s c(e).

I Claim: Algorithm terminates in at most C iterations.

I Claim: Algorithm runs in O(mC ) time.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 35: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Termination of the Ford-Fulkerson Algorithm

I Claim: at each stage, flow values and residual capacities are integers. Proveby induction.

I Claim: Flow value strictly increases when we apply augment(f ,P).v(f ′) = v(f ) + bottleneck(P, f ) > v(f ).

I Claim: Maximum value of any flow is C =∑

e out of s c(e).

I Claim: Algorithm terminates in at most C iterations.

I Claim: Algorithm runs in O(mC ) time.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 36: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Termination of the Ford-Fulkerson Algorithm

I Claim: at each stage, flow values and residual capacities are integers. Proveby induction.

I Claim: Flow value strictly increases when we apply augment(f ,P).v(f ′) = v(f ) + bottleneck(P, f ) > v(f ).

I Claim: Maximum value of any flow is C =∑

e out of s c(e).

I Claim: Algorithm terminates in at most C iterations.

I Claim: Algorithm runs in O(mC ) time.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 37: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Termination of the Ford-Fulkerson Algorithm

I Claim: at each stage, flow values and residual capacities are integers. Proveby induction.

I Claim: Flow value strictly increases when we apply augment(f ,P).v(f ′) = v(f ) + bottleneck(P, f ) > v(f ).

I Claim: Maximum value of any flow is C =∑

e out of s c(e).

I Claim: Algorithm terminates in at most C iterations.

I Claim: Algorithm runs in O(mC ) time.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 38: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Termination of the Ford-Fulkerson Algorithm

I Claim: at each stage, flow values and residual capacities are integers. Proveby induction.

I Claim: Flow value strictly increases when we apply augment(f ,P).v(f ′) = v(f ) + bottleneck(P, f ) > v(f ).

I Claim: Maximum value of any flow is C =∑

e out of s c(e).

I Claim: Algorithm terminates in at most C iterations.

I Claim: Algorithm runs in O(mC ) time.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 39: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Ford-Fulkerson Algorithm

I How large can the flow be?

I Can we characterise the magnitude of the flow in terms of the structure ofthe graph? For example, for every flow f , ν(f ) ≤ C =

∑e out of s c(e).

I Is there a better bound?

I Idea: An s-t cut is a partition of V into sets A and B such that s ∈ A andt ∈ B.

I Capacity of the cut (A,B) is c(A,B) =∑

e out of A c(e).I Intuition: For every flow f , ν(f ) ≤ c(A,B).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 40: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Ford-Fulkerson Algorithm

I How large can the flow be?

I Can we characterise the magnitude of the flow in terms of the structure ofthe graph? For example, for every flow f , ν(f ) ≤ C =

∑e out of s c(e).

I Is there a better bound?

I Idea: An s-t cut is a partition of V into sets A and B such that s ∈ A andt ∈ B.

I Capacity of the cut (A,B) is c(A,B) =∑

e out of A c(e).I Intuition: For every flow f , ν(f ) ≤ c(A,B).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 41: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Ford-Fulkerson Algorithm

I How large can the flow be?I Can we characterise the magnitude of the flow in terms of the structure of

the graph? For example, for every flow f , ν(f ) ≤ C =∑

e out of s c(e).I Is there a better bound?I Idea: An s-t cut is a partition of V into sets A and B such that s ∈ A and

t ∈ B.

I Capacity of the cut (A,B) is c(A,B) =∑

e out of A c(e).I Intuition: For every flow f , ν(f ) ≤ c(A,B).

A B

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 42: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Ford-Fulkerson Algorithm

I How large can the flow be?I Can we characterise the magnitude of the flow in terms of the structure of

the graph? For example, for every flow f , ν(f ) ≤ C =∑

e out of s c(e).I Is there a better bound?I Idea: An s-t cut is a partition of V into sets A and B such that s ∈ A and

t ∈ B.I Capacity of the cut (A,B) is c(A,B) =

∑e out of A c(e).

I Intuition: For every flow f , ν(f ) ≤ c(A,B).

A B

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 43: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Some Useful Notation

A B

f out(v) =∑

e out of v

f (e) f in(v) =∑

e into v

f (e)

For S ⊆ V ,

f out(S) =∑

e out of S

f (e) f in(S) =∑

e into S

f (e)

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 44: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Fun Facts about Cuts

A B

I Let f be any s-t flow and (A,B) any s-t cut.

I Claim: ν(f ) = f out(A)− f in(A).

I ν(f ) = f out(s) and f in(s) = 0⇒ ν(f ) = f out(s)− f in(s).I For every other node v ∈ A, 0 = f out(v)− f in(v).I Summing up all these equations, ν(f ) =

∑v∈A

(f out(v)− f in(v)

).

I An edge e that has both ends in A or both ends out of A does not contribute.I An edge e that has its tail in A contributes f (e).I An edge e that has its head in A contributes −f (e).

I∑

v∈A(f out(v)− f in(v)

)=∑

e out of A f (e)−∑

e into A f (e) = f out(A)− f in(A).

I Corollary: ν(f ) = f in(B)− f out(B).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 45: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Fun Facts about Cuts

A B

I Let f be any s-t flow and (A,B) any s-t cut.I Claim: ν(f ) = f out(A)− f in(A).

I ν(f ) = f out(s) and f in(s) = 0⇒ ν(f ) = f out(s)− f in(s).I For every other node v ∈ A, 0 = f out(v)− f in(v).I Summing up all these equations, ν(f ) =

∑v∈A

(f out(v)− f in(v)

).

I An edge e that has both ends in A or both ends out of A does not contribute.I An edge e that has its tail in A contributes f (e).I An edge e that has its head in A contributes −f (e).

I∑

v∈A(f out(v)− f in(v)

)=∑

e out of A f (e)−∑

e into A f (e) = f out(A)− f in(A).

I Corollary: ν(f ) = f in(B)− f out(B).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 46: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Fun Facts about Cuts

A B

I Let f be any s-t flow and (A,B) any s-t cut.I Claim: ν(f ) = f out(A)− f in(A).

I ν(f ) = f out(s) and f in(s) = 0⇒ ν(f ) = f out(s)− f in(s).

I For every other node v ∈ A, 0 = f out(v)− f in(v).I Summing up all these equations, ν(f ) =

∑v∈A

(f out(v)− f in(v)

).

I An edge e that has both ends in A or both ends out of A does not contribute.I An edge e that has its tail in A contributes f (e).I An edge e that has its head in A contributes −f (e).

I∑

v∈A(f out(v)− f in(v)

)=∑

e out of A f (e)−∑

e into A f (e) = f out(A)− f in(A).

I Corollary: ν(f ) = f in(B)− f out(B).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 47: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Fun Facts about Cuts

A B

I Let f be any s-t flow and (A,B) any s-t cut.I Claim: ν(f ) = f out(A)− f in(A).

I ν(f ) = f out(s) and f in(s) = 0⇒ ν(f ) = f out(s)− f in(s).I For every other node v ∈ A, 0 = f out(v)− f in(v).

I Summing up all these equations, ν(f ) =∑

v∈A(f out(v)− f in(v)

).

I An edge e that has both ends in A or both ends out of A does not contribute.I An edge e that has its tail in A contributes f (e).I An edge e that has its head in A contributes −f (e).

I∑

v∈A(f out(v)− f in(v)

)=∑

e out of A f (e)−∑

e into A f (e) = f out(A)− f in(A).

I Corollary: ν(f ) = f in(B)− f out(B).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 48: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Fun Facts about Cuts

A B

I Let f be any s-t flow and (A,B) any s-t cut.I Claim: ν(f ) = f out(A)− f in(A).

I ν(f ) = f out(s) and f in(s) = 0⇒ ν(f ) = f out(s)− f in(s).I For every other node v ∈ A, 0 = f out(v)− f in(v).I Summing up all these equations, ν(f ) =

∑v∈A

(f out(v)− f in(v)

).

I An edge e that has both ends in A or both ends out of A does not contribute.I An edge e that has its tail in A contributes f (e).I An edge e that has its head in A contributes −f (e).

I∑

v∈A(f out(v)− f in(v)

)=∑

e out of A f (e)−∑

e into A f (e) = f out(A)− f in(A).

I Corollary: ν(f ) = f in(B)− f out(B).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 49: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Fun Facts about Cuts

A B

I Let f be any s-t flow and (A,B) any s-t cut.I Claim: ν(f ) = f out(A)− f in(A).

I ν(f ) = f out(s) and f in(s) = 0⇒ ν(f ) = f out(s)− f in(s).I For every other node v ∈ A, 0 = f out(v)− f in(v).I Summing up all these equations, ν(f ) =

∑v∈A

(f out(v)− f in(v)

).

I An edge e that has both ends in A or both ends out of A does not contribute.I An edge e that has its tail in A contributes f (e).I An edge e that has its head in A contributes −f (e).

I∑

v∈A(f out(v)− f in(v)

)=∑

e out of A f (e)−∑

e into A f (e) = f out(A)− f in(A).

I Corollary: ν(f ) = f in(B)− f out(B).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 50: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Fun Facts about Cuts

A B

I Let f be any s-t flow and (A,B) any s-t cut.I Claim: ν(f ) = f out(A)− f in(A).

I ν(f ) = f out(s) and f in(s) = 0⇒ ν(f ) = f out(s)− f in(s).I For every other node v ∈ A, 0 = f out(v)− f in(v).I Summing up all these equations, ν(f ) =

∑v∈A

(f out(v)− f in(v)

).

I An edge e that has both ends in A or both ends out of A does not contribute.I An edge e that has its tail in A contributes f (e).I An edge e that has its head in A contributes −f (e).

I∑

v∈A(f out(v)− f in(v)

)=∑

e out of A f (e)−∑

e into A f (e) = f out(A)− f in(A).I Corollary: ν(f ) = f in(B)− f out(B).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 51: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Important Fact about Cuts

A B

I ν(f ) ≤ c(A,B).

ν(f ) = f out(A)− f in(A)

≤ f out(A) =∑

e out of A

f (e)

≤∑

e out of A

c(e) = c(A,B).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 52: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Important Fact about Cuts

A B

I ν(f ) ≤ c(A,B).

ν(f ) = f out(A)− f in(A)

≤ f out(A) =∑

e out of A

f (e)

≤∑

e out of A

c(e) = c(A,B).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 53: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Max-Flows and Min-Cuts

I Let f be any s-t flow and (A,B) any s-t cut. We proved ν(f ) ≤ c(A,B).

I Very strong statement: The value of every flow is ≤ capacity of any cut.

I Corollary: The maximum flow is at most the smallest capacity of a cut.

I Question: Is the reverse true? Is the smallest capacity of a cut at most themaximum flow?

I Answer: Yes, and the Ford-Fulkerson algorithm computes this cut!

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 54: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Max-Flows and Min-Cuts

I Let f be any s-t flow and (A,B) any s-t cut. We proved ν(f ) ≤ c(A,B).

I Very strong statement: The value of every flow is ≤ capacity of any cut.

I Corollary: The maximum flow is at most the smallest capacity of a cut.

I Question: Is the reverse true? Is the smallest capacity of a cut at most themaximum flow?

I Answer: Yes, and the Ford-Fulkerson algorithm computes this cut!

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 55: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Max-Flows and Min-Cuts

I Let f be any s-t flow and (A,B) any s-t cut. We proved ν(f ) ≤ c(A,B).

I Very strong statement: The value of every flow is ≤ capacity of any cut.

I Corollary: The maximum flow is at most the smallest capacity of a cut.

I Question: Is the reverse true? Is the smallest capacity of a cut at most themaximum flow?

I Answer: Yes, and the Ford-Fulkerson algorithm computes this cut!

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 56: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Max-Flows and Min-Cuts

I Let f be any s-t flow and (A,B) any s-t cut. We proved ν(f ) ≤ c(A,B).

I Very strong statement: The value of every flow is ≤ capacity of any cut.

I Corollary: The maximum flow is at most the smallest capacity of a cut.

I Question: Is the reverse true? Is the smallest capacity of a cut at most themaximum flow?

I Answer: Yes, and the Ford-Fulkerson algorithm computes this cut!

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 57: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Flows and Cuts

I Let f̄ denote the flow computed by the Ford-Fulkerson algorithm.

I Enough to show ∃ s-t cut (A∗,B∗) such that ν(f̄ ) = c(A∗,B∗).

I When the algorithm terminates, the residual graph has no s-t path.

I Claim: If f is an s-t flow such that Gf has no s-t path, then there is an s-tcut (A∗,B∗) such that ν(f ) = c(A∗,B∗).

I Claim applies to any flow f such that Gf has no s-t path, and not just to theflow f̄ computed by the Ford-Fulkerson algorithm.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 58: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Flows and Cuts

I Let f̄ denote the flow computed by the Ford-Fulkerson algorithm.

I Enough to show ∃ s-t cut (A∗,B∗) such that ν(f̄ ) = c(A∗,B∗).

I When the algorithm terminates, the residual graph has no s-t path.

I Claim: If f is an s-t flow such that Gf has no s-t path, then there is an s-tcut (A∗,B∗) such that ν(f ) = c(A∗,B∗).

I Claim applies to any flow f such that Gf has no s-t path, and not just to theflow f̄ computed by the Ford-Fulkerson algorithm.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 59: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Proof of Claim Relating Flows to Cuts

I Claim: f is an s-t flow and Gf has no s-t path ⇒ ∃ s-t cut (A∗,B∗),ν(f ) = c(A∗,B∗).

I A∗ = set of nodes reachable from s in Gf , B∗ = V − A∗.

I Claim: (A∗,B∗) is an s-t cut in G .

I Claim: If e = (u, v) such thatu ∈ A∗, v ∈ B∗, then

f (e) = c(e).

I Claim: If e′ = (u′, v ′) such thatu′ ∈ B∗, v ′ ∈ A∗, then

f (e′) = 0.

I Claim: ν(f ) = c(A∗,B∗).

ν(f ) = f out(A)− f in(A)

=∑

e out of A

f (e)−∑

e into A

f (e)

=∑

e out of A

c(e)−∑

e into A

0 = c(A,B).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 60: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Proof of Claim Relating Flows to Cuts

I Claim: f is an s-t flow and Gf has no s-t path ⇒ ∃ s-t cut (A∗,B∗),ν(f ) = c(A∗,B∗).

I A∗ = set of nodes reachable from s in Gf , B∗ = V − A∗.

I Claim: (A∗,B∗) is an s-t cut in G .

I Claim: If e = (u, v) such thatu ∈ A∗, v ∈ B∗, then

f (e) = c(e).

I Claim: If e′ = (u′, v ′) such thatu′ ∈ B∗, v ′ ∈ A∗, then

f (e′) = 0.

I Claim: ν(f ) = c(A∗,B∗).

ν(f ) = f out(A)− f in(A)

=∑

e out of A

f (e)−∑

e into A

f (e)

=∑

e out of A

c(e)−∑

e into A

0 = c(A,B).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 61: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Proof of Claim Relating Flows to Cuts

I Claim: f is an s-t flow and Gf has no s-t path ⇒ ∃ s-t cut (A∗,B∗),ν(f ) = c(A∗,B∗).

I A∗ = set of nodes reachable from s in Gf , B∗ = V − A∗.

I Claim: (A∗,B∗) is an s-t cut in G .

I Claim: If e = (u, v) such thatu ∈ A∗, v ∈ B∗, then

f (e) = c(e).

I Claim: If e′ = (u′, v ′) such thatu′ ∈ B∗, v ′ ∈ A∗, then

f (e′) = 0.

I Claim: ν(f ) = c(A∗,B∗).

ν(f ) = f out(A)− f in(A)

=∑

e out of A

f (e)−∑

e into A

f (e)

=∑

e out of A

c(e)−∑

e into A

0 = c(A,B).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 62: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Proof of Claim Relating Flows to Cuts

I Claim: f is an s-t flow and Gf has no s-t path ⇒ ∃ s-t cut (A∗,B∗),ν(f ) = c(A∗,B∗).

I A∗ = set of nodes reachable from s in Gf , B∗ = V − A∗.

I Claim: (A∗,B∗) is an s-t cut in G .

I Claim: If e = (u, v) such thatu ∈ A∗, v ∈ B∗, then

f (e) = c(e).

I Claim: If e′ = (u′, v ′) such thatu′ ∈ B∗, v ′ ∈ A∗, then

f (e′) = 0.

I Claim: ν(f ) = c(A∗,B∗).

ν(f ) = f out(A)− f in(A)

=∑

e out of A

f (e)−∑

e into A

f (e)

=∑

e out of A

c(e)−∑

e into A

0 = c(A,B).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 63: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Proof of Claim Relating Flows to Cuts

I Claim: f is an s-t flow and Gf has no s-t path ⇒ ∃ s-t cut (A∗,B∗),ν(f ) = c(A∗,B∗).

I A∗ = set of nodes reachable from s in Gf , B∗ = V − A∗.

I Claim: (A∗,B∗) is an s-t cut in G .

I Claim: If e = (u, v) such thatu ∈ A∗, v ∈ B∗, then f (e) = c(e).

I Claim: If e′ = (u′, v ′) such thatu′ ∈ B∗, v ′ ∈ A∗, then

f (e′) = 0.

I Claim: ν(f ) = c(A∗,B∗).

ν(f ) = f out(A)− f in(A)

=∑

e out of A

f (e)−∑

e into A

f (e)

=∑

e out of A

c(e)−∑

e into A

0 = c(A,B).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 64: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Proof of Claim Relating Flows to Cuts

I Claim: f is an s-t flow and Gf has no s-t path ⇒ ∃ s-t cut (A∗,B∗),ν(f ) = c(A∗,B∗).

I A∗ = set of nodes reachable from s in Gf , B∗ = V − A∗.

I Claim: (A∗,B∗) is an s-t cut in G .

I Claim: If e = (u, v) such thatu ∈ A∗, v ∈ B∗, then f (e) = c(e).

I Claim: If e′ = (u′, v ′) such thatu′ ∈ B∗, v ′ ∈ A∗, then

f (e′) = 0.

I Claim: ν(f ) = c(A∗,B∗).

ν(f ) = f out(A)− f in(A)

=∑

e out of A

f (e)−∑

e into A

f (e)

=∑

e out of A

c(e)−∑

e into A

0 = c(A,B).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 65: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Proof of Claim Relating Flows to Cuts

I Claim: f is an s-t flow and Gf has no s-t path ⇒ ∃ s-t cut (A∗,B∗),ν(f ) = c(A∗,B∗).

I A∗ = set of nodes reachable from s in Gf , B∗ = V − A∗.

I Claim: (A∗,B∗) is an s-t cut in G .

I Claim: If e = (u, v) such thatu ∈ A∗, v ∈ B∗, then f (e) = c(e).

I Claim: If e′ = (u′, v ′) such thatu′ ∈ B∗, v ′ ∈ A∗, then

f (e′) = 0.

I Claim: ν(f ) = c(A∗,B∗).

ν(f ) = f out(A)− f in(A)

=∑

e out of A

f (e)−∑

e into A

f (e)

=∑

e out of A

c(e)−∑

e into A

0 = c(A,B).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 66: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Proof of Claim Relating Flows to Cuts

I Claim: f is an s-t flow and Gf has no s-t path ⇒ ∃ s-t cut (A∗,B∗),ν(f ) = c(A∗,B∗).

I A∗ = set of nodes reachable from s in Gf , B∗ = V − A∗.

I Claim: (A∗,B∗) is an s-t cut in G .

I Claim: If e = (u, v) such thatu ∈ A∗, v ∈ B∗, then f (e) = c(e).

I Claim: If e′ = (u′, v ′) such thatu′ ∈ B∗, v ′ ∈ A∗, then f (e′) = 0.

I Claim: ν(f ) = c(A∗,B∗).

ν(f ) = f out(A)− f in(A)

=∑

e out of A

f (e)−∑

e into A

f (e)

=∑

e out of A

c(e)−∑

e into A

0 = c(A,B).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 67: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Proof of Claim Relating Flows to Cuts

I Claim: f is an s-t flow and Gf has no s-t path ⇒ ∃ s-t cut (A∗,B∗),ν(f ) = c(A∗,B∗).

I A∗ = set of nodes reachable from s in Gf , B∗ = V − A∗.

I Claim: (A∗,B∗) is an s-t cut in G .

I Claim: If e = (u, v) such thatu ∈ A∗, v ∈ B∗, then f (e) = c(e).

I Claim: If e′ = (u′, v ′) such thatu′ ∈ B∗, v ′ ∈ A∗, then f (e′) = 0.

I Claim: ν(f ) = c(A∗,B∗).

ν(f ) = f out(A)− f in(A)

=∑

e out of A

f (e)−∑

e into A

f (e)

=∑

e out of A

c(e)−∑

e into A

0 = c(A,B).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 68: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Proof of Claim Relating Flows to Cuts

I Claim: f is an s-t flow and Gf has no s-t path ⇒ ∃ s-t cut (A∗,B∗),ν(f ) = c(A∗,B∗).

I A∗ = set of nodes reachable from s in Gf , B∗ = V − A∗.

I Claim: (A∗,B∗) is an s-t cut in G .

I Claim: If e = (u, v) such thatu ∈ A∗, v ∈ B∗, then f (e) = c(e).

I Claim: If e′ = (u′, v ′) such thatu′ ∈ B∗, v ′ ∈ A∗, then f (e′) = 0.

I Claim: ν(f ) = c(A∗,B∗).

ν(f ) = f out(A)− f in(A)

=∑

e out of A

f (e)−∑

e into A

f (e)

=∑

e out of A

c(e)−∑

e into A

0 = c(A,B).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 69: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Max-Flow Min-Cut Theorem

I The flow f̄ computed by the Ford-Fulkerson algorithm is a maximum flow.

I Given a flow of maximum value, we can compute a minimum s-t cut in O(m)time.

I In every flow network, there is a flow f and a cut (A,B) such thatν(f ) = c(A,B).

I Max-Flow Min-Cut Theorem: in every flow network, the maximum value ofan s-t flow is equal to the minimum capacity of an s-t cut.

I Corollary: If all capacities in a flow network are integers, then there is amaximum flow f where f (e), the value of the flow on edge e, is an integerfor every edge e in G .

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 70: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Max-Flow Min-Cut Theorem

I The flow f̄ computed by the Ford-Fulkerson algorithm is a maximum flow.

I Given a flow of maximum value, we can compute a minimum s-t cut in O(m)time.

I In every flow network, there is a flow f and a cut (A,B) such thatν(f ) = c(A,B).

I Max-Flow Min-Cut Theorem: in every flow network, the maximum value ofan s-t flow is equal to the minimum capacity of an s-t cut.

I Corollary: If all capacities in a flow network are integers, then there is amaximum flow f where f (e), the value of the flow on edge e, is an integerfor every edge e in G .

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 71: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Max-Flow Min-Cut Theorem

I The flow f̄ computed by the Ford-Fulkerson algorithm is a maximum flow.

I Given a flow of maximum value, we can compute a minimum s-t cut in O(m)time.

I In every flow network, there is a flow f and a cut (A,B) such thatν(f ) = c(A,B).

I Max-Flow Min-Cut Theorem: in every flow network, the maximum value ofan s-t flow is equal to the minimum capacity of an s-t cut.

I Corollary: If all capacities in a flow network are integers, then there is amaximum flow f where f (e), the value of the flow on edge e, is an integerfor every edge e in G .

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 72: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Real-Valued Capacities

I If capacities are real-valued, Ford-Fulkerson algorithm may not terminate!

I But Max-Flow Min-Cut theorem is still true. Why?

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 73: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Bad Augmenting Paths

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 74: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Improving Ford-Fulkerson Algorithm

I Bad case for Ford-Fulkerson algorithm is when the bottleneck edge is theaugmenting path has a low capacity.

I Idea: decrease number of iterations by picking s-t path with bottleneck edgeof largest capacity.

Computing this path can slow down each iterationconsiderably.

I Modified idea: Maintain a scaling parameter ∆ and choose only augmentingpaths with bottleneck capacity at least ∆.

I Gf (∆): residual network restricted to edges with residual capacities ≥ ∆.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 75: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Improving Ford-Fulkerson Algorithm

I Bad case for Ford-Fulkerson algorithm is when the bottleneck edge is theaugmenting path has a low capacity.

I Idea: decrease number of iterations by picking s-t path with bottleneck edgeof largest capacity. Computing this path can slow down each iterationconsiderably.

I Modified idea: Maintain a scaling parameter ∆ and choose only augmentingpaths with bottleneck capacity at least ∆.

I Gf (∆): residual network restricted to edges with residual capacities ≥ ∆.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 76: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Improving Ford-Fulkerson Algorithm

I Bad case for Ford-Fulkerson algorithm is when the bottleneck edge is theaugmenting path has a low capacity.

I Idea: decrease number of iterations by picking s-t path with bottleneck edgeof largest capacity. Computing this path can slow down each iterationconsiderably.

I Modified idea: Maintain a scaling parameter ∆ and choose only augmentingpaths with bottleneck capacity at least ∆.

I Gf (∆): residual network restricted to edges with residual capacities ≥ ∆.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 77: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Improving Ford-Fulkerson Algorithm

I Bad case for Ford-Fulkerson algorithm is when the bottleneck edge is theaugmenting path has a low capacity.

I Idea: decrease number of iterations by picking s-t path with bottleneck edgeof largest capacity. Computing this path can slow down each iterationconsiderably.

I Modified idea: Maintain a scaling parameter ∆ and choose only augmentingpaths with bottleneck capacity at least ∆.

I Gf (∆): residual network restricted to edges with residual capacities ≥ ∆.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 78: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Scaling Max-Flow Algorithm

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 79: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Scaling Max-Flow Algorithm

I Flow and residual capacities are integer valued throughout.

I When ∆ = 1, Gf (∆) and Gf are identical.

I Therefore, when the scaling algorithm terminates, the flow is a maximumflow.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 80: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Running time of the Scaling Max-Flow Algorithm I

I ∆-scaling phase: one iteration of the algorithm’s outer loop, with ∆ fixed.

I Claim: the number of ∆-scaling phases is at most

1 + dlog2 Ce.I Need to bound the number of iterations in each ∆-scaling phase.

I Claim: During a ∆-scaling phase, each iteration increases the flow by ≥ ∆.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 81: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Running time of the Scaling Max-Flow Algorithm I

I ∆-scaling phase: one iteration of the algorithm’s outer loop, with ∆ fixed.

I Claim: the number of ∆-scaling phases is at most 1 + dlog2 Ce.

I Need to bound the number of iterations in each ∆-scaling phase.

I Claim: During a ∆-scaling phase, each iteration increases the flow by ≥ ∆.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 82: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Running time of the Scaling Max-Flow Algorithm I

I ∆-scaling phase: one iteration of the algorithm’s outer loop, with ∆ fixed.

I Claim: the number of ∆-scaling phases is at most 1 + dlog2 Ce.I Need to bound the number of iterations in each ∆-scaling phase.

I Claim: During a ∆-scaling phase, each iteration increases the flow by ≥ ∆.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 83: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Running time of the Scaling Max-Flow Algorithm I

I ∆-scaling phase: one iteration of the algorithm’s outer loop, with ∆ fixed.

I Claim: the number of ∆-scaling phases is at most 1 + dlog2 Ce.I Need to bound the number of iterations in each ∆-scaling phase.

I Claim: During a ∆-scaling phase, each iteration increases the flow by ≥ ∆.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 84: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Running time of the Scaling Max-Flow Algorithm I

I ∆-scaling phase: one iteration of the algorithm’s outer loop, with ∆ fixed.

I Claim: the number of ∆-scaling phases is at most 1 + dlog2 Ce.I Need to bound the number of iterations in each ∆-scaling phase.

I Claim: During a ∆-scaling phase, each iteration increases the flow by ≥ ∆.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 85: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Value of Flow at the End of a ∆-Scaling PhaseI Let f be the flow at the end of a ∆-scaling phase.I Claim: Then there is an s-t cut in (A,B) in G such that

ν(f ) ≤ ν(f̄ ) ≤ c(A,B) ≤ ν(f ) + m∆

I There is no s-t path in Gf (∆).I Let A∗ be the set of nodes reachable from s in Gf (∆); B∗ = V − A∗.I Claim: (A∗,B∗) is an s-t cut in G .I Claim: If e = (u, v) such that u ∈ A∗, v ∈ B∗, then

c(e)− f (e) < ∆.

I Claim: If e′ = (u′, v ′) such that u′ ∈ B∗, v ′ ∈ A∗, then

f (e′) < ∆.

I Claim: ν(f ) ≥ c(A∗,B∗)−m∆.

ν(f ) = f out(A∗)− f in(A∗)

=∑

e out of A∗

f (e)−∑

e into A∗

f (e)

≥∑

e out of A∗

(c(e)−∆)−∑

e into A∗

≥∑

e out of A∗

c(e)−∑e in G

≥ c(A∗,B∗)−m∆.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 86: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Value of Flow at the End of a ∆-Scaling PhaseI Let f be the flow at the end of a ∆-scaling phase.I Claim: Then there is an s-t cut in (A,B) in G such that

ν(f ) ≤ ν(f̄ ) ≤ c(A,B) ≤ ν(f ) + m∆

I There is no s-t path in Gf (∆).

I Let A∗ be the set of nodes reachable from s in Gf (∆); B∗ = V − A∗.I Claim: (A∗,B∗) is an s-t cut in G .I Claim: If e = (u, v) such that u ∈ A∗, v ∈ B∗, then

c(e)− f (e) < ∆.

I Claim: If e′ = (u′, v ′) such that u′ ∈ B∗, v ′ ∈ A∗, then

f (e′) < ∆.

I Claim: ν(f ) ≥ c(A∗,B∗)−m∆.

ν(f ) = f out(A∗)− f in(A∗)

=∑

e out of A∗

f (e)−∑

e into A∗

f (e)

≥∑

e out of A∗

(c(e)−∆)−∑

e into A∗

≥∑

e out of A∗

c(e)−∑e in G

≥ c(A∗,B∗)−m∆.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 87: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Value of Flow at the End of a ∆-Scaling PhaseI Let f be the flow at the end of a ∆-scaling phase.I Claim: Then there is an s-t cut in (A,B) in G such that

ν(f ) ≤ ν(f̄ ) ≤ c(A,B) ≤ ν(f ) + m∆

I There is no s-t path in Gf (∆).I Let A∗ be the set of nodes reachable from s in Gf (∆); B∗ = V − A∗.

I Claim: (A∗,B∗) is an s-t cut in G .I Claim: If e = (u, v) such that u ∈ A∗, v ∈ B∗, then

c(e)− f (e) < ∆.

I Claim: If e′ = (u′, v ′) such that u′ ∈ B∗, v ′ ∈ A∗, then

f (e′) < ∆.

I Claim: ν(f ) ≥ c(A∗,B∗)−m∆.

ν(f ) = f out(A∗)− f in(A∗)

=∑

e out of A∗

f (e)−∑

e into A∗

f (e)

≥∑

e out of A∗

(c(e)−∆)−∑

e into A∗

≥∑

e out of A∗

c(e)−∑e in G

≥ c(A∗,B∗)−m∆.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 88: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Value of Flow at the End of a ∆-Scaling PhaseI Let f be the flow at the end of a ∆-scaling phase.I Claim: Then there is an s-t cut in (A,B) in G such that

ν(f ) ≤ ν(f̄ ) ≤ c(A,B) ≤ ν(f ) + m∆

I There is no s-t path in Gf (∆).I Let A∗ be the set of nodes reachable from s in Gf (∆); B∗ = V − A∗.I Claim: (A∗,B∗) is an s-t cut in G .

I Claim: If e = (u, v) such that u ∈ A∗, v ∈ B∗, then

c(e)− f (e) < ∆.

I Claim: If e′ = (u′, v ′) such that u′ ∈ B∗, v ′ ∈ A∗, then

f (e′) < ∆.

I Claim: ν(f ) ≥ c(A∗,B∗)−m∆.

ν(f ) = f out(A∗)− f in(A∗)

=∑

e out of A∗

f (e)−∑

e into A∗

f (e)

≥∑

e out of A∗

(c(e)−∆)−∑

e into A∗

≥∑

e out of A∗

c(e)−∑e in G

≥ c(A∗,B∗)−m∆.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 89: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Value of Flow at the End of a ∆-Scaling PhaseI Let f be the flow at the end of a ∆-scaling phase.I Claim: Then there is an s-t cut in (A,B) in G such that

ν(f ) ≤ ν(f̄ ) ≤ c(A,B) ≤ ν(f ) + m∆

I There is no s-t path in Gf (∆).I Let A∗ be the set of nodes reachable from s in Gf (∆); B∗ = V − A∗.I Claim: (A∗,B∗) is an s-t cut in G .I Claim: If e = (u, v) such that u ∈ A∗, v ∈ B∗, then

c(e)− f (e) < ∆.I Claim: If e′ = (u′, v ′) such that u′ ∈ B∗, v ′ ∈ A∗, then

f (e′) < ∆.

I Claim: ν(f ) ≥ c(A∗,B∗)−m∆.

ν(f ) = f out(A∗)− f in(A∗)

=∑

e out of A∗

f (e)−∑

e into A∗

f (e)

≥∑

e out of A∗

(c(e)−∆)−∑

e into A∗

≥∑

e out of A∗

c(e)−∑e in G

≥ c(A∗,B∗)−m∆.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 90: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Value of Flow at the End of a ∆-Scaling PhaseI Let f be the flow at the end of a ∆-scaling phase.I Claim: Then there is an s-t cut in (A,B) in G such that

ν(f ) ≤ ν(f̄ ) ≤ c(A,B) ≤ ν(f ) + m∆

I There is no s-t path in Gf (∆).I Let A∗ be the set of nodes reachable from s in Gf (∆); B∗ = V − A∗.I Claim: (A∗,B∗) is an s-t cut in G .I Claim: If e = (u, v) such that u ∈ A∗, v ∈ B∗, then c(e)− f (e) < ∆.

I Claim: If e′ = (u′, v ′) such that u′ ∈ B∗, v ′ ∈ A∗, then

f (e′) < ∆.

I Claim: ν(f ) ≥ c(A∗,B∗)−m∆.

ν(f ) = f out(A∗)− f in(A∗)

=∑

e out of A∗

f (e)−∑

e into A∗

f (e)

≥∑

e out of A∗

(c(e)−∆)−∑

e into A∗

≥∑

e out of A∗

c(e)−∑e in G

≥ c(A∗,B∗)−m∆.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 91: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Value of Flow at the End of a ∆-Scaling PhaseI Let f be the flow at the end of a ∆-scaling phase.I Claim: Then there is an s-t cut in (A,B) in G such that

ν(f ) ≤ ν(f̄ ) ≤ c(A,B) ≤ ν(f ) + m∆

I There is no s-t path in Gf (∆).I Let A∗ be the set of nodes reachable from s in Gf (∆); B∗ = V − A∗.I Claim: (A∗,B∗) is an s-t cut in G .I Claim: If e = (u, v) such that u ∈ A∗, v ∈ B∗, then c(e)− f (e) < ∆.I Claim: If e′ = (u′, v ′) such that u′ ∈ B∗, v ′ ∈ A∗, then

f (e′) < ∆.I Claim: ν(f ) ≥ c(A∗,B∗)−m∆.

ν(f ) = f out(A∗)− f in(A∗)

=∑

e out of A∗

f (e)−∑

e into A∗

f (e)

≥∑

e out of A∗

(c(e)−∆)−∑

e into A∗

≥∑

e out of A∗

c(e)−∑e in G

≥ c(A∗,B∗)−m∆.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 92: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Value of Flow at the End of a ∆-Scaling PhaseI Let f be the flow at the end of a ∆-scaling phase.I Claim: Then there is an s-t cut in (A,B) in G such that

ν(f ) ≤ ν(f̄ ) ≤ c(A,B) ≤ ν(f ) + m∆

I There is no s-t path in Gf (∆).I Let A∗ be the set of nodes reachable from s in Gf (∆); B∗ = V − A∗.I Claim: (A∗,B∗) is an s-t cut in G .I Claim: If e = (u, v) such that u ∈ A∗, v ∈ B∗, then c(e)− f (e) < ∆.I Claim: If e′ = (u′, v ′) such that u′ ∈ B∗, v ′ ∈ A∗, then f (e′) < ∆.

I Claim: ν(f ) ≥ c(A∗,B∗)−m∆.

ν(f ) = f out(A∗)− f in(A∗)

=∑

e out of A∗

f (e)−∑

e into A∗

f (e)

≥∑

e out of A∗

(c(e)−∆)−∑

e into A∗

≥∑

e out of A∗

c(e)−∑e in G

≥ c(A∗,B∗)−m∆.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 93: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Value of Flow at the End of a ∆-Scaling PhaseI Let f be the flow at the end of a ∆-scaling phase.I Claim: Then there is an s-t cut in (A,B) in G such that

ν(f ) ≤ ν(f̄ ) ≤ c(A,B) ≤ ν(f ) + m∆

I There is no s-t path in Gf (∆).I Let A∗ be the set of nodes reachable from s in Gf (∆); B∗ = V − A∗.I Claim: (A∗,B∗) is an s-t cut in G .I Claim: If e = (u, v) such that u ∈ A∗, v ∈ B∗, then c(e)− f (e) < ∆.I Claim: If e′ = (u′, v ′) such that u′ ∈ B∗, v ′ ∈ A∗, then f (e′) < ∆.I Claim: ν(f ) ≥ c(A∗,B∗)−m∆.

ν(f ) = f out(A∗)− f in(A∗)

=∑

e out of A∗

f (e)−∑

e into A∗

f (e)

≥∑

e out of A∗

(c(e)−∆)−∑

e into A∗

≥∑

e out of A∗

c(e)−∑e in G

≥ c(A∗,B∗)−m∆.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 94: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Value of Flow at the End of a ∆-Scaling PhaseI Let f be the flow at the end of a ∆-scaling phase.I Claim: Then there is an s-t cut in (A,B) in G such that

ν(f ) ≤ ν(f̄ ) ≤ c(A,B) ≤ ν(f ) + m∆

I There is no s-t path in Gf (∆).I Let A∗ be the set of nodes reachable from s in Gf (∆); B∗ = V − A∗.I Claim: (A∗,B∗) is an s-t cut in G .I Claim: If e = (u, v) such that u ∈ A∗, v ∈ B∗, then c(e)− f (e) < ∆.I Claim: If e′ = (u′, v ′) such that u′ ∈ B∗, v ′ ∈ A∗, then f (e′) < ∆.I Claim: ν(f ) ≥ c(A∗,B∗)−m∆.

ν(f ) = f out(A∗)− f in(A∗)

=∑

e out of A∗

f (e)−∑

e into A∗

f (e)

≥∑

e out of A∗

(c(e)−∆)−∑

e into A∗

≥∑

e out of A∗

c(e)−∑e in G

≥ c(A∗,B∗)−m∆.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 95: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Running time of the Scaling Max-Flow Algorithm II

I Claim: the number of augmentations in a ∆-scaling phase is ≤ 2m.I Base case: In the first ∆-scaling phase, each edge incident on s can be used in

at most one augmenting path.I Induction: At the end of the some ∆-scaling phase, let value of ∆ be Γ and let

f ′ be the flow: ν(f ′) ≥ ν(f̄ )−mΓ.

I In the next ∆-scaling phase, the value of ∆ is Γ/2. Let f be the flow at theend of this phase.

I Since each iteration increases the flow by ≥ Γ/2, if the current ∆-scaling phasecontinues for more than 2m iterations, then ν(f ) ≥ ν(f ′) + 2mΓ/2 ≥ ν(f̄ ).

I Claim: the running time of the scaling max-flow algorithm is O(m2 log C ).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 96: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Running time of the Scaling Max-Flow Algorithm II

I Claim: the number of augmentations in a ∆-scaling phase is ≤ 2m.I Base case: In the first ∆-scaling phase, each edge incident on s can be used in

at most one augmenting path.I Induction: At the end of the some ∆-scaling phase, let value of ∆ be Γ and let

f ′ be the flow: ν(f ′) ≥ ν(f̄ )−mΓ.I In the next ∆-scaling phase, the value of ∆ is Γ/2. Let f be the flow at the

end of this phase.I Since each iteration increases the flow by ≥ Γ/2, if the current ∆-scaling phase

continues for more than 2m iterations, then ν(f ) ≥ ν(f ′) + 2mΓ/2 ≥ ν(f̄ ).I Claim: the running time of the scaling max-flow algorithm is O(m2 log C ).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 97: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Other Maximum Flow Algorithms

I Running time of the Ford-Fulkerson algorithm is O(mC ), which ispseudo-polynomial: polynomial in the magnitudes of the numbers in theinput.

I Scaling algorithm runs in time polynomial in the size of the input (the graphand the number of bits needed to represent the capacities).

I Desire a strongly polynomial algorithm: running time is depends only on thesize of the graph and is independent of the numerical values of the capacities(as long as numerical operations take O(1) time).

I Edmonds-Karp, Dinitz: choose augmenting path to be the shortest path inGf (use breadth-first search). Algorithm runs in O(mn) iterations.

I Improved algorithms take time O(mn log n), O(n3), etc.

I Chapter 7.4: Preflow-push max-flow algorithm that is not based onaugmenting paths. Runs in O(n2m) or O(n3) time.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 98: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Other Maximum Flow Algorithms

I Running time of the Ford-Fulkerson algorithm is O(mC ), which ispseudo-polynomial: polynomial in the magnitudes of the numbers in theinput.

I Scaling algorithm runs in time polynomial in the size of the input (the graphand the number of bits needed to represent the capacities).

I Desire a strongly polynomial algorithm: running time is depends only on thesize of the graph and is independent of the numerical values of the capacities(as long as numerical operations take O(1) time).

I Edmonds-Karp, Dinitz: choose augmenting path to be the shortest path inGf (use breadth-first search). Algorithm runs in O(mn) iterations.

I Improved algorithms take time O(mn log n), O(n3), etc.

I Chapter 7.4: Preflow-push max-flow algorithm that is not based onaugmenting paths. Runs in O(n2m) or O(n3) time.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 99: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Other Maximum Flow Algorithms

I Running time of the Ford-Fulkerson algorithm is O(mC ), which ispseudo-polynomial: polynomial in the magnitudes of the numbers in theinput.

I Scaling algorithm runs in time polynomial in the size of the input (the graphand the number of bits needed to represent the capacities).

I Desire a strongly polynomial algorithm: running time is depends only on thesize of the graph and is independent of the numerical values of the capacities(as long as numerical operations take O(1) time).

I Edmonds-Karp, Dinitz: choose augmenting path to be the shortest path inGf (use breadth-first search). Algorithm runs in O(mn) iterations.

I Improved algorithms take time O(mn log n), O(n3), etc.

I Chapter 7.4: Preflow-push max-flow algorithm that is not based onaugmenting paths. Runs in O(n2m) or O(n3) time.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 100: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Global Min CutI Given an undirected graph G = (V ,E ), a cut is a partition of V into two

non-empty sets A and B.I Note distinction from s-t cut, where we had a directed graph, two

distinguished nodes s and t, and sought to separate s from t.

I Size of a cut (A,B) is the number of edges with one endpoint in A and theother endpoint in B.

I A global minimum cut is a cut of minimum size over all cuts.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 101: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Algorithm for Global Min Cut

1. Pick an arbitrary vertex s ∈ V . The global min cut must separate s from atleast one other vertex t in V .

2. Try every other vertex in V as a candidate for t and compute the minimums-t cut.

3. Pick smallest overall cut.

I Algorithm has a polynomial running time: involves n − 1 computations ofminimum s-t cut.

I Appears that finding global min cut is “harder” than finding minimum s-tcut.

I Many algorithms can compute global min-cut just as fast as the minimum s-tcut and do not even require a notion of flow.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 102: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Algorithm for Global Min Cut

1. Pick an arbitrary vertex s ∈ V . The global min cut must separate s from atleast one other vertex t in V .

2. Try every other vertex in V as a candidate for t and compute the minimums-t cut.

3. Pick smallest overall cut.

I Algorithm has a polynomial running time: involves n − 1 computations ofminimum s-t cut.

I Appears that finding global min cut is “harder” than finding minimum s-tcut.

I Many algorithms can compute global min-cut just as fast as the minimum s-tcut and do not even require a notion of flow.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 103: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Edge Contraction

I Due to Karger and Stein in 1992.

I Randomised algorithm.

I Based on the notion of edge contraction:I Pick an edge (u, v).I Unify u and v into a new “supernode” w ; delete u and v .I Delete edges connecting u to v .I Make every edge of the form (x , u) be incident on x and w .I Make every edge of the form (x , v) be incident on x and w .I An edge may be incident on w multiple times, i.e., the graph is a multigraph.

I Key idea of the algorithm is to pick edges at random and keep contracting tillthe graph has two nodes.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 104: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Edge Contraction

I Due to Karger and Stein in 1992.

I Randomised algorithm.

I Based on the notion of edge contraction:I Pick an edge (u, v).I Unify u and v into a new “supernode” w ; delete u and v .I Delete edges connecting u to v .I Make every edge of the form (x , u) be incident on x and w .I Make every edge of the form (x , v) be incident on x and w .I An edge may be incident on w multiple times, i.e., the graph is a multigraph.

I Key idea of the algorithm is to pick edges at random and keep contracting tillthe graph has two nodes.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 105: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Randomised Contraction Algorithm

I For each node v , record the set S(v) of nodes that we have contracted into v .

I Initially, S(v) = v for every node v .

Contraction(G):

If G has two nodes v1 and v2, return the cut (S(v1),S(v2)).else

Choose an edge e = (u, v) in G uniformly at random.

Contract e using the new node w to replace u and v.Let G ′ be the resulting graph.

Set S(w) = S(u) ∪ S(v)Contraction(G ′).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 106: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Randomised Contraction Algorithm

I For each node v , record the set S(v) of nodes that we have contracted into v .

I Initially, S(v) = v for every node v .

Contraction(G):

If G has two nodes v1 and v2, return the cut (S(v1),S(v2)).else

Choose an edge e = (u, v) in G uniformly at random.

Contract e using the new node w to replace u and v.Let G ′ be the resulting graph.

Set S(w) = S(u) ∪ S(v)Contraction(G ′).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 107: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Contraction Algorithm: I

I Let (A,B) be a global min cut of size k ; let F be the set of edges in the cut.

I How many edges must be incident on each node?

≥ k.

I Therefore, G has at least kn/2 edges.

I What can go “wrong” in the first step of the algorithm? The algorithm mayselect an edge in F for contraction. Then it cannot return the cut (A,B).

I What is the probability of this bad event? ≤ k/(kn/2) = 2/n.

I Consider the graph after j contractions.I How many supernodes? ≥ n − j .I How many edges if no edge in F contracted yet? ≥ k(n − j)/2.I What is the probability that the next contraction will be along an edge in F?≤ 2/(n − j).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 108: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Contraction Algorithm: I

I Let (A,B) be a global min cut of size k ; let F be the set of edges in the cut.

I How many edges must be incident on each node? ≥ k.

I Therefore, G has at least kn/2 edges.

I What can go “wrong” in the first step of the algorithm? The algorithm mayselect an edge in F for contraction. Then it cannot return the cut (A,B).

I What is the probability of this bad event? ≤ k/(kn/2) = 2/n.

I Consider the graph after j contractions.I How many supernodes? ≥ n − j .I How many edges if no edge in F contracted yet? ≥ k(n − j)/2.I What is the probability that the next contraction will be along an edge in F?≤ 2/(n − j).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 109: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Contraction Algorithm: I

I Let (A,B) be a global min cut of size k ; let F be the set of edges in the cut.

I How many edges must be incident on each node? ≥ k.

I Therefore, G has at least kn/2 edges.

I What can go “wrong” in the first step of the algorithm?

The algorithm mayselect an edge in F for contraction. Then it cannot return the cut (A,B).

I What is the probability of this bad event? ≤ k/(kn/2) = 2/n.

I Consider the graph after j contractions.I How many supernodes? ≥ n − j .I How many edges if no edge in F contracted yet? ≥ k(n − j)/2.I What is the probability that the next contraction will be along an edge in F?≤ 2/(n − j).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 110: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Contraction Algorithm: I

I Let (A,B) be a global min cut of size k ; let F be the set of edges in the cut.

I How many edges must be incident on each node? ≥ k.

I Therefore, G has at least kn/2 edges.

I What can go “wrong” in the first step of the algorithm? The algorithm mayselect an edge in F for contraction. Then it cannot return the cut (A,B).

I What is the probability of this bad event? ≤ k/(kn/2) = 2/n.

I Consider the graph after j contractions.I How many supernodes? ≥ n − j .I How many edges if no edge in F contracted yet? ≥ k(n − j)/2.I What is the probability that the next contraction will be along an edge in F?≤ 2/(n − j).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 111: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Contraction Algorithm: I

I Let (A,B) be a global min cut of size k ; let F be the set of edges in the cut.

I How many edges must be incident on each node? ≥ k.

I Therefore, G has at least kn/2 edges.

I What can go “wrong” in the first step of the algorithm? The algorithm mayselect an edge in F for contraction. Then it cannot return the cut (A,B).

I What is the probability of this bad event?

≤ k/(kn/2) = 2/n.

I Consider the graph after j contractions.I How many supernodes? ≥ n − j .I How many edges if no edge in F contracted yet? ≥ k(n − j)/2.I What is the probability that the next contraction will be along an edge in F?≤ 2/(n − j).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 112: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Contraction Algorithm: I

I Let (A,B) be a global min cut of size k ; let F be the set of edges in the cut.

I How many edges must be incident on each node? ≥ k.

I Therefore, G has at least kn/2 edges.

I What can go “wrong” in the first step of the algorithm? The algorithm mayselect an edge in F for contraction. Then it cannot return the cut (A,B).

I What is the probability of this bad event? ≤ k/(kn/2) = 2/n.

I Consider the graph after j contractions.I How many supernodes? ≥ n − j .I How many edges if no edge in F contracted yet? ≥ k(n − j)/2.I What is the probability that the next contraction will be along an edge in F?≤ 2/(n − j).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 113: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Contraction Algorithm: I

I Let (A,B) be a global min cut of size k ; let F be the set of edges in the cut.

I How many edges must be incident on each node? ≥ k.

I Therefore, G has at least kn/2 edges.

I What can go “wrong” in the first step of the algorithm? The algorithm mayselect an edge in F for contraction. Then it cannot return the cut (A,B).

I What is the probability of this bad event? ≤ k/(kn/2) = 2/n.

I Consider the graph after j contractions.

I How many supernodes? ≥ n − j .I How many edges if no edge in F contracted yet? ≥ k(n − j)/2.I What is the probability that the next contraction will be along an edge in F?≤ 2/(n − j).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 114: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Contraction Algorithm: I

I Let (A,B) be a global min cut of size k ; let F be the set of edges in the cut.

I How many edges must be incident on each node? ≥ k.

I Therefore, G has at least kn/2 edges.

I What can go “wrong” in the first step of the algorithm? The algorithm mayselect an edge in F for contraction. Then it cannot return the cut (A,B).

I What is the probability of this bad event? ≤ k/(kn/2) = 2/n.

I Consider the graph after j contractions.I How many supernodes?

≥ n − j .I How many edges if no edge in F contracted yet? ≥ k(n − j)/2.I What is the probability that the next contraction will be along an edge in F?≤ 2/(n − j).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 115: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Contraction Algorithm: I

I Let (A,B) be a global min cut of size k ; let F be the set of edges in the cut.

I How many edges must be incident on each node? ≥ k.

I Therefore, G has at least kn/2 edges.

I What can go “wrong” in the first step of the algorithm? The algorithm mayselect an edge in F for contraction. Then it cannot return the cut (A,B).

I What is the probability of this bad event? ≤ k/(kn/2) = 2/n.

I Consider the graph after j contractions.I How many supernodes? ≥ n − j .

I How many edges if no edge in F contracted yet? ≥ k(n − j)/2.I What is the probability that the next contraction will be along an edge in F?≤ 2/(n − j).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 116: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Contraction Algorithm: I

I Let (A,B) be a global min cut of size k ; let F be the set of edges in the cut.

I How many edges must be incident on each node? ≥ k.

I Therefore, G has at least kn/2 edges.

I What can go “wrong” in the first step of the algorithm? The algorithm mayselect an edge in F for contraction. Then it cannot return the cut (A,B).

I What is the probability of this bad event? ≤ k/(kn/2) = 2/n.

I Consider the graph after j contractions.I How many supernodes? ≥ n − j .I How many edges if no edge in F contracted yet?

≥ k(n − j)/2.I What is the probability that the next contraction will be along an edge in F?≤ 2/(n − j).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 117: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Contraction Algorithm: I

I Let (A,B) be a global min cut of size k ; let F be the set of edges in the cut.

I How many edges must be incident on each node? ≥ k.

I Therefore, G has at least kn/2 edges.

I What can go “wrong” in the first step of the algorithm? The algorithm mayselect an edge in F for contraction. Then it cannot return the cut (A,B).

I What is the probability of this bad event? ≤ k/(kn/2) = 2/n.

I Consider the graph after j contractions.I How many supernodes? ≥ n − j .I How many edges if no edge in F contracted yet? ≥ k(n − j)/2.

I What is the probability that the next contraction will be along an edge in F?≤ 2/(n − j).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 118: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Contraction Algorithm: I

I Let (A,B) be a global min cut of size k ; let F be the set of edges in the cut.

I How many edges must be incident on each node? ≥ k.

I Therefore, G has at least kn/2 edges.

I What can go “wrong” in the first step of the algorithm? The algorithm mayselect an edge in F for contraction. Then it cannot return the cut (A,B).

I What is the probability of this bad event? ≤ k/(kn/2) = 2/n.

I Consider the graph after j contractions.I How many supernodes? ≥ n − j .I How many edges if no edge in F contracted yet? ≥ k(n − j)/2.I What is the probability that the next contraction will be along an edge in F?

≤ 2/(n − j).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 119: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Contraction Algorithm: I

I Let (A,B) be a global min cut of size k ; let F be the set of edges in the cut.

I How many edges must be incident on each node? ≥ k.

I Therefore, G has at least kn/2 edges.

I What can go “wrong” in the first step of the algorithm? The algorithm mayselect an edge in F for contraction. Then it cannot return the cut (A,B).

I What is the probability of this bad event? ≤ k/(kn/2) = 2/n.

I Consider the graph after j contractions.I How many supernodes? ≥ n − j .I How many edges if no edge in F contracted yet? ≥ k(n − j)/2.I What is the probability that the next contraction will be along an edge in F?≤ 2/(n − j).

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 120: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Contraction Algorithm: II

I We want to estimate the probability that the algorithm will return the cut(A,B), i.e., the algorithm does not select any edge in F in any of theiterations 1 ≤ j ≤ n − 2.

I Let ξj denote the event that no edge in F is contracted in iteration j of thealgorithm.

I What do we want to compute? A lower bound on Pr[ξ1 ∩ ξ2 . . . ∩ ξn−2]I What have we shown so far?

Pr[ξ1] ≥ (1− 2/n) = (n − 2)/nPr[ξj+1|ξ1 ∩ ξ2 . . . ∩ ξj ] ≥ (n − j − 2)/(n − j)

Pr[ξ1 ∩ ξ2 . . . ∩ ξn−2] =

Pr[ξ1] Pr[ξ2|ξ1] Pr[ξ3|ξ1 ∩ ξ2] . . .Pr[ξj+1|ξ1 ∩ ξ2 . . . ∩ ξj ] . . .Pr[ξn−2|ξ1 ∩ ξ2 . . . ∩ ξn−3]

≥(

n − 2

n

)(n − 3

n − 1

). . .

(n − j − 2

n − j

). . .

(2

4

)(1

3

)=

2

n(n − 1)=

(n

2

)−1

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 121: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Contraction Algorithm: II

I We want to estimate the probability that the algorithm will return the cut(A,B), i.e., the algorithm does not select any edge in F in any of theiterations 1 ≤ j ≤ n − 2.

I Let ξj denote the event that no edge in F is contracted in iteration j of thealgorithm.

I What do we want to compute? A lower bound on Pr[ξ1 ∩ ξ2 . . . ∩ ξn−2]I What have we shown so far?

Pr[ξ1] ≥ (1− 2/n) = (n − 2)/nPr[ξj+1|ξ1 ∩ ξ2 . . . ∩ ξj ] ≥ (n − j − 2)/(n − j)

Pr[ξ1 ∩ ξ2 . . . ∩ ξn−2] =

Pr[ξ1] Pr[ξ2|ξ1] Pr[ξ3|ξ1 ∩ ξ2] . . .Pr[ξj+1|ξ1 ∩ ξ2 . . . ∩ ξj ] . . .Pr[ξn−2|ξ1 ∩ ξ2 . . . ∩ ξn−3]

≥(

n − 2

n

)(n − 3

n − 1

). . .

(n − j − 2

n − j

). . .

(2

4

)(1

3

)=

2

n(n − 1)=

(n

2

)−1

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 122: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Contraction Algorithm: II

I We want to estimate the probability that the algorithm will return the cut(A,B), i.e., the algorithm does not select any edge in F in any of theiterations 1 ≤ j ≤ n − 2.

I Let ξj denote the event that no edge in F is contracted in iteration j of thealgorithm.

I What do we want to compute?

A lower bound on Pr[ξ1 ∩ ξ2 . . . ∩ ξn−2]I What have we shown so far?

Pr[ξ1] ≥ (1− 2/n) = (n − 2)/nPr[ξj+1|ξ1 ∩ ξ2 . . . ∩ ξj ] ≥ (n − j − 2)/(n − j)

Pr[ξ1 ∩ ξ2 . . . ∩ ξn−2] =

Pr[ξ1] Pr[ξ2|ξ1] Pr[ξ3|ξ1 ∩ ξ2] . . .Pr[ξj+1|ξ1 ∩ ξ2 . . . ∩ ξj ] . . .Pr[ξn−2|ξ1 ∩ ξ2 . . . ∩ ξn−3]

≥(

n − 2

n

)(n − 3

n − 1

). . .

(n − j − 2

n − j

). . .

(2

4

)(1

3

)=

2

n(n − 1)=

(n

2

)−1

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 123: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Contraction Algorithm: II

I We want to estimate the probability that the algorithm will return the cut(A,B), i.e., the algorithm does not select any edge in F in any of theiterations 1 ≤ j ≤ n − 2.

I Let ξj denote the event that no edge in F is contracted in iteration j of thealgorithm.

I What do we want to compute? A lower bound on Pr[ξ1 ∩ ξ2 . . . ∩ ξn−2]

I What have we shown so far?Pr[ξ1] ≥ (1− 2/n) = (n − 2)/nPr[ξj+1|ξ1 ∩ ξ2 . . . ∩ ξj ] ≥ (n − j − 2)/(n − j)

Pr[ξ1 ∩ ξ2 . . . ∩ ξn−2] =

Pr[ξ1] Pr[ξ2|ξ1] Pr[ξ3|ξ1 ∩ ξ2] . . .Pr[ξj+1|ξ1 ∩ ξ2 . . . ∩ ξj ] . . .Pr[ξn−2|ξ1 ∩ ξ2 . . . ∩ ξn−3]

≥(

n − 2

n

)(n − 3

n − 1

). . .

(n − j − 2

n − j

). . .

(2

4

)(1

3

)=

2

n(n − 1)=

(n

2

)−1

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 124: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Contraction Algorithm: II

I We want to estimate the probability that the algorithm will return the cut(A,B), i.e., the algorithm does not select any edge in F in any of theiterations 1 ≤ j ≤ n − 2.

I Let ξj denote the event that no edge in F is contracted in iteration j of thealgorithm.

I What do we want to compute? A lower bound on Pr[ξ1 ∩ ξ2 . . . ∩ ξn−2]I What have we shown so far?

Pr[ξ1] ≥ (1− 2/n) = (n − 2)/n

Pr[ξj+1|ξ1 ∩ ξ2 . . . ∩ ξj ] ≥ (n − j − 2)/(n − j)

Pr[ξ1 ∩ ξ2 . . . ∩ ξn−2] =

Pr[ξ1] Pr[ξ2|ξ1] Pr[ξ3|ξ1 ∩ ξ2] . . .Pr[ξj+1|ξ1 ∩ ξ2 . . . ∩ ξj ] . . .Pr[ξn−2|ξ1 ∩ ξ2 . . . ∩ ξn−3]

≥(

n − 2

n

)(n − 3

n − 1

). . .

(n − j − 2

n − j

). . .

(2

4

)(1

3

)=

2

n(n − 1)=

(n

2

)−1

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 125: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Contraction Algorithm: II

I We want to estimate the probability that the algorithm will return the cut(A,B), i.e., the algorithm does not select any edge in F in any of theiterations 1 ≤ j ≤ n − 2.

I Let ξj denote the event that no edge in F is contracted in iteration j of thealgorithm.

I What do we want to compute? A lower bound on Pr[ξ1 ∩ ξ2 . . . ∩ ξn−2]I What have we shown so far?

Pr[ξ1] ≥ (1− 2/n) = (n − 2)/nPr[ξj+1|ξ1 ∩ ξ2 . . . ∩ ξj ] ≥ (n − j − 2)/(n − j)

Pr[ξ1 ∩ ξ2 . . . ∩ ξn−2] =

Pr[ξ1] Pr[ξ2|ξ1] Pr[ξ3|ξ1 ∩ ξ2] . . .Pr[ξj+1|ξ1 ∩ ξ2 . . . ∩ ξj ] . . .Pr[ξn−2|ξ1 ∩ ξ2 . . . ∩ ξn−3]

≥(

n − 2

n

)(n − 3

n − 1

). . .

(n − j − 2

n − j

). . .

(2

4

)(1

3

)=

2

n(n − 1)=

(n

2

)−1

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 126: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Correctness of the Contraction Algorithm: II

I We want to estimate the probability that the algorithm will return the cut(A,B), i.e., the algorithm does not select any edge in F in any of theiterations 1 ≤ j ≤ n − 2.

I Let ξj denote the event that no edge in F is contracted in iteration j of thealgorithm.

I What do we want to compute? A lower bound on Pr[ξ1 ∩ ξ2 . . . ∩ ξn−2]I What have we shown so far?

Pr[ξ1] ≥ (1− 2/n) = (n − 2)/nPr[ξj+1|ξ1 ∩ ξ2 . . . ∩ ξj ] ≥ (n − j − 2)/(n − j)

Pr[ξ1 ∩ ξ2 . . . ∩ ξn−2] =

Pr[ξ1] Pr[ξ2|ξ1] Pr[ξ3|ξ1 ∩ ξ2] . . .Pr[ξj+1|ξ1 ∩ ξ2 . . . ∩ ξj ] . . .Pr[ξn−2|ξ1 ∩ ξ2 . . . ∩ ξn−3]

≥(

n − 2

n

)(n − 3

n − 1

). . .

(n − j − 2

n − j

). . .

(2

4

)(1

3

)=

2

n(n − 1)=

(n

2

)−1T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 127: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Number of Runs of the Contraction Algorithm

I One run of the algorithm produces the global min cut with a probability at

least(n2

)−1.

I How can we amplify this probability?

Run the algorithm many times andoutput the largest cut we find.

I If we run the algorithm(n2

)times, then the probability that we do not find

the global min cut in any run is at(1− 1/

(n

2

))(n2)≤ 1/e.

I Can we drive the probability of failure further down? If we run the algorithm(n2

)ln n times, then the probability of failure is at most 1/n.

I Several other optimisations can improve overall running time considerably.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 128: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Number of Runs of the Contraction Algorithm

I One run of the algorithm produces the global min cut with a probability at

least(n2

)−1.

I How can we amplify this probability? Run the algorithm many times andoutput the largest cut we find.

I If we run the algorithm(n2

)times, then the probability that we do not find

the global min cut in any run is at(1− 1/

(n

2

))(n2)≤ 1/e.

I Can we drive the probability of failure further down? If we run the algorithm(n2

)ln n times, then the probability of failure is at most 1/n.

I Several other optimisations can improve overall running time considerably.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 129: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Number of Runs of the Contraction Algorithm

I One run of the algorithm produces the global min cut with a probability at

least(n2

)−1.

I How can we amplify this probability? Run the algorithm many times andoutput the largest cut we find.

I If we run the algorithm(n2

)times, then the probability that we do not find

the global min cut in any run is at(1− 1/

(n

2

))(n2)

≤ 1/e.

I Can we drive the probability of failure further down? If we run the algorithm(n2

)ln n times, then the probability of failure is at most 1/n.

I Several other optimisations can improve overall running time considerably.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 130: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Number of Runs of the Contraction Algorithm

I One run of the algorithm produces the global min cut with a probability at

least(n2

)−1.

I How can we amplify this probability? Run the algorithm many times andoutput the largest cut we find.

I If we run the algorithm(n2

)times, then the probability that we do not find

the global min cut in any run is at(1− 1/

(n

2

))(n2)≤ 1/e.

I Can we drive the probability of failure further down?

If we run the algorithm(n2

)ln n times, then the probability of failure is at most 1/n.

I Several other optimisations can improve overall running time considerably.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 131: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Number of Runs of the Contraction Algorithm

I One run of the algorithm produces the global min cut with a probability at

least(n2

)−1.

I How can we amplify this probability? Run the algorithm many times andoutput the largest cut we find.

I If we run the algorithm(n2

)times, then the probability that we do not find

the global min cut in any run is at(1− 1/

(n

2

))(n2)≤ 1/e.

I Can we drive the probability of failure further down? If we run the algorithm(n2

)ln n times, then the probability of failure is at most 1/n.

I Several other optimisations can improve overall running time considerably.

T. M. Murali February 12, 2014 CS 6824: Network Flow

Page 132: CS 6824: Network Flowcourses.cs.vt.edu/cs6824/2014-spring/lectures/... · CS 6824: Network Flow T. M. Murali February 12, 2014 T. M. Murali February 12, 2014 CS 6824: Network Flow

Number of Runs of the Contraction Algorithm

I One run of the algorithm produces the global min cut with a probability at

least(n2

)−1.

I How can we amplify this probability? Run the algorithm many times andoutput the largest cut we find.

I If we run the algorithm(n2

)times, then the probability that we do not find

the global min cut in any run is at(1− 1/

(n

2

))(n2)≤ 1/e.

I Can we drive the probability of failure further down? If we run the algorithm(n2

)ln n times, then the probability of failure is at most 1/n.

I Several other optimisations can improve overall running time considerably.

T. M. Murali February 12, 2014 CS 6824: Network Flow