Algorithms Tutorial Questions: Flow Networks and Ford-Fulkerson Algorithm, Exercises of Algorithms and Programming

[Week 10] Flow Network, Minimum Cut vs Maximum Flow, Ford-Fulkerson

Typology: Exercises

2018/2019

Uploaded on 06/15/2019

kefart
kefart 🇺🇸

4.4

(11)

55 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Tutorial questionsAlgorithms 9007
2019 Semester 1Tutorial 8
The University of Sydney
School of Computer Science
Pre-tutorial questions
Do you know the basic concepts of this week’s lecture content? These questions are only to test yourself.
They will not be explicitly discussed in the tutorial, and no solutions will be given to them.
1. Flow network G= (V, E).
(a) Is Gdirected or undirected?
(b) What does it mean that an edge has a capacity?
(c) What is a flow fin G?
(d) Why is the flow of an edge bounded by the capacity of an edge?
(e) What are the capacity and conservation constraints?
2. Min Cut (A,B ) of G.
(a) What is a cut (A,B ) of G?
(b) What is the capacity of a cut?
(c) What is the flow of a cut?
3. Min cut vs. max flow
(a) Why is the value of a cut an upper bound on the maximum flow?
(b) What does the Min Cut - Max Flow theorem state?
4. Ford-Fulkerson
(a) The Ford-Fulkerson algorithm iteratively increases the flow. How is this done in each iteration?
(b) Can you upper bound the number of iterations performed by the Ford-Fulkerson algorithm?
Tutorial
Problem 1
Let G= (V, E ) be an arbitrary flow network, with source s, sink t, and edge capacities c:EZ+. Decide
whether each of the following statements are true of false. If it is true, give a short explanation. If it is false,
give a counterexample.
1. If fis a maximum s-tflow in G, then fsaturates every edge out of s; that is, f(e) = c(e) for each
edge ecoming out of s.
2. Let (A, B ) be a minimum s-tcut with respect to c. Define new capacities ˆc(e) = c(e) + 1 for each
eE. Then (A, B) is a minimum s-tcut with respect ˆc.
1
pf3
pf4
pf5

Partial preview of the text

Download Algorithms Tutorial Questions: Flow Networks and Ford-Fulkerson Algorithm and more Exercises Algorithms and Programming in PDF only on Docsity!

Algorithms 9007 Tutorial questions 2019 Semester 1 Tutorial 8

The University of Sydney School of Computer Science

Pre-tutorial questions

Do you know the basic concepts of this week's lecture content? These questions are only to test yourself. They will not be explicitly discussed in the tutorial, and no solutions will be given to them.

  1. Flow network G = (V, E).

(a) Is G directed or undirected? (b) What does it mean that an edge has a capacity? (c) What is a ow f in G? (d) Why is the ow of an edge bounded by the capacity of an edge? (e) What are the capacity and conservation constraints?

  1. Min Cut (A, B) of G.

(a) What is a cut (A, B) of G? (b) What is the capacity of a cut? (c) What is the ow of a cut?

  1. Min cut vs. max ow

(a) Why is the value of a cut an upper bound on the maximum ow? (b) What does the Min Cut - Max Flow theorem state?

  1. Ford-Fulkerson

(a) The Ford-Fulkerson algorithm iteratively increases the ow. How is this done in each iteration? (b) Can you upper bound the number of iterations performed by the Ford-Fulkerson algorithm?

Tutorial

Problem 1 Let G = (V, E) be an arbitrary ow network, with source s, sink t, and edge capacities c : E → Z+. Decide whether each of the following statements are true of false. If it is true, give a short explanation. If it is false, give a counterexample.

  1. If f is a maximum s-t ow in G, then f saturates every edge out of s; that is, f (e) = c(e) for each edge e coming out of s.
  2. Let (A, B) be a minimum s-t cut with respect to c. De ne new capacities ^c(e) = c(e) + 1 for each e ∈ E. Then (A, B) is a minimum s-t cut with respect ^c.

Solution: 1. This is False. The following graphs is a counter example.

s 2 u 1 v 2 t

  1. This is False. The following graph is a counter example. The cut ({s, u 1 , u 2 }, {v 1 , v 2 , t}) is minimum before the update but not after.

s t

u 1

u 2 v 2

v 1

Problem 2 The gure below shows a ow network on which an s − t ow is shown. The capacity of each edge appears as a label next to the edge, and the numbers in boxes give the amount of ow sent on each edge. (Edges without boxed numbers have no ow being sent on them.)

  1. What is the value of this ow?
  2. Is this a maximum s − t ow in this graph? If not, nd a maximum s − t ow.
  3. Find a minimum s − t cut. (Specify which vertices belong to the sets of the cut.)

s t

w

x y

z

s

u

t

w

Solution: First, there are exactly four possible cuts in the graph. These are (recalling that the cut must separate s and t):

(a) {s}, {u, w, t},

(b) {s, u}, {w, t},

(c) {s, w}, {u, t}, and

(d) {s, u, w}, {t}.

It is a simple matter to determine the capacity of each of these cuts, and nd those that are minimum cuts. In the order given above, the capacities of the cuts are 4, 6, 4, and 4. So we see that there are three minimum cuts in this graph, namely

(a) {s}, {u, w, t},

(b) {s, w}, {u, t}, and

(c) {s, u, w}, {t}.

Problem 4 Design a linear time algorithm that given a ow f veri es that f is maximum. If the ow is maximum your algorithm should output \yes", otherwise, it should output \no". No other action is required.

Solution: Given the input graph G and f , construct Gf in linear time and check if there is an s-t path. If there is an s-t path then we could use the path to push one extra unit of ow, so f is not maximum. Otherwise, we reach the termination criterion of the Ford-Fulkerson algorithm, which means that f is maximum.

Problem 5 Consider a generalization of the maximum ow problem where vertices have capacities. An instance is de ned by a directed graph G = (V, E), a pair of vertices s and t, and vertex capacities c : V → Z+. A ow f : E → Z+^ is feasible if f out(u) ≤ c(u). The objective is to nd a maximum feasible s-t ow. Design an efficient algorithm for this problem.

Solution: The high level idea is to enforce the vertex capacity with a standard edge capacity. To achieve this, we split every vertex u into two nodes (uin^ and uout) and connect them using and edge with capacity c(u). For every edge (u, v) in the input graph, we create an edge (uout, vin) with capacity +∞. The following picture shows how a vertex u and its incoming and outgoing edges are transformed by the reduction. Let G = (V, E) be the input graph and G′^ the graph obtained by the reduction. Let f be an s-t ow in G obeying the vertex constraints. We de ne a ow f ′^ in G′^ as follows. For each (u, v) ∈ E set f ′(uout, vin) = f (u, v); for each vertex u ∈ V set f ′(uin, uout) = f out(u). It is easy to show that this is a feasible sout-tin^ ow in G′^ with the same value as f. Similarly, given a feasible ow sout-tin^ ow f ′^ in G′, we can nd a feasible s-t ow in G with the same value as f ′. Therefore, solving the edge-capacitated maximum ow problem in G′ is equivalent to the vertex-capacitated maximum ow problem in G.

x

y

u c(u)

v

xout

yout

uin c(u)

uout^ vin

Problem 6 Consider a generalization of the minimum cut problem where we want to separate two sets of vertices. An instance is de ned by a graph G = (V, E), a pair of disjoint subsets of vertices S, T ⊆ V , and edge capacities c : E → Z+. The objective is to nd a minimum capacity cut (A, B) such that S ⊆ A and T ⊆ B. Design an efficient algorithm for this problem.

Solution: Let G′^ be the graph obtained from G by adding two new vertices s and t and edges {(s, u) : u ∈ S} ∪ {(v, t) : v ∈ T } with capacity ∞. Let (A′, B′) be an s-t cut in G′. If S ⊆ A′^ and T ⊆ B′^ the capacity of (A′, B′) equals the capacity of (A′^ − s, B′^ − t); otherwise, the capacity is +∞. Therefore, there is a one-to-one correspondence between minimum s-t cuts in G′^ and minimum S-T cuts in G.