Docsity

Maximum Flow-Theory of Complexity and Algorithms-Assignment Solution, Exercises of Advanced Algorithms

Toggle sidebar
bg1
Max Flow, Min Cut, and Matchings (Solution)
1. The figure below shows a flow network on which an s-tflow is shown.
The capacity of each edge appears as a label next to the edge, and the
numbers in boxes give the amount of flow sent on each edge. (Edges
without boxed numbers have no flow being sent on them.)
(a) What is the value of this flow?
(b) Is this a maximum s-tflow in this graph? If not, find a maximum
s-tflow.
(c) Find a minimum s-tcut. (Specify which vertices belong to the
sets of the cut.)
llll
l
l
- - -
๎˜๎˜๎˜๎˜๎˜๎˜๎˜๎˜๎˜๎˜๎˜๎˜๎˜
๎˜1
PPPPPPPPPPPPP
Pq
PPPPPPPPPPPPP
Pq
๎˜๎˜๎˜๎˜๎˜๎˜๎˜๎˜๎˜๎˜๎˜๎˜๎˜
๎˜1
๎˜€๎˜€๎˜€๎˜€๎˜’
@@@@R
@@@@R
๎˜€๎˜€๎˜€๎˜€๎˜’
s tx y
w
z
44
77
10 6
2
2
2
2
10 7
10 4
77
66
Solution:
(a) The value of this flow is 17. (The total amount of flow passing
from sto t.)
(b) No, this isnโ€™t a maximum flow. We can find a maximum flow by
looking at the residual network. In this case, from the given flow,
we can get a max flow with only a single augmenting path, as
shown in the picture below.
1
docsity.com
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Maximum Flow-Theory of Complexity and Algorithms-Assignment Solution and more Exercises Advanced Algorithms in PDF only on Docsity!

Max Flow, Min Cut, and Matchings (Solution)

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

(a) What is the value of this flow? (b) Is this a maximum s-t flow in this graph? If not, find a maximum s-t flow. (c) Find a minimum s-t cut. (Specify which vertices belong to the sets of the cut.)

l l l l

l

l

 - - - 







 1

PPP PPP PPP PPP PPq

PP PPP PPP PPP PPPq









^1



@ @ @ @R

@ @ @ @R



s x y t

w

z

Solution:

(a) The value of this flow is 17. (The total amount of flow passing from s to t.) (b) No, this isnโ€™t a maximum flow. We can find a maximum flow by looking at the residual network. In this case, from the given flow, we can get a max flow with only a single augmenting path, as shown in the picture below.

So the maximum flow has value 19.

(c) As explained in class, we can find a minimum cut using the resid- ual network for the final maximum flow. Starting at s, find all vertices that are reachable from s in the residual network. This

s c (^) d

a

b

t

3

Solution:

(a)

Thus, the max flow has value 13. Note that the flow shown is not unique, i.e. there are other possible maximum flows in the network, but they will all have the same value of 13. (b) As in problem (1), start from s and find which vertices can be reached in the final residual network for one set of the cut, and the remaining vertices form the other set. So one minimum cut is {s, a, b, c} {d, t}. The (forwards) edges across this cut are (a, d), (a, t), (c, d), and (b, t). The capacities of those edges are, respectively, 2, 3 , 4, and 4, the sum of which is 13 (which it should be according to the Max Flow/Min Cut Theorem). Note, also in this case that the minimum cut isnโ€™t unique. For example, the cut consisting of the two sets {s, a, b, c, d} and {t} also has capacity 13.

  1. Network flows come up in dealing with natural disasters and other crises, since treatment of injured people and/or evacuation of large numbers of people without overloading hospitals and roads is neces- sary.

to 1. In order to handle the โ€œbalanceโ€ constraint, for each edge from a hospital to t, take the capacity of that edge to equal

โŒˆ (^) n k

โŒ‰ (this is an integer, recall the definition that the brackets means the โ€œceilingโ€ of the number inside). (Why do these capacities on all the edges work to do the task we want? If there is a maximum flow of value n, why does this give an evacuation schedule for all n patients?) This leaves us with a flow network with integer capacities on the edges. So we can use the Edmonds-Karp network flow algorithm to find a maximum flow. If the value of the maximum flow turns out to be n, then we now there is a procedure that allows us to evacuate all the patients and maintain the balance amongst the hospitals (once again, why?). If the value of the maximum flow is less than n, then there is no balanced evacuation procedure (and, I hope, the paramedics try some other procedure to get all the patients to some set of hospitals). Building the graph takes time O(nk). (Each of the n people can be joined to at most k hospitals, and adding the additional edges to s and t takes time O(n) and O(k) respectively, so, overall the whole flow network takes time O(nk) to construct.) Using the Edmonds- Karp variation of the maximum flow problem, we find the maximum flow in time O((n + k + 2)(nk + n + k)^2 )) โˆˆ O((n + k)n^2 k^2 ). (Recall that the Edmonds-Karp maximum flow algorithm takes time O(ve^2 ), where v is the number of vertices, and e is the number of edges. In this case we have v = n + k + 2 and e โˆˆ O(nk + n + k).)

  1. Suppose you live with n โˆ’ 1 other people in an off-campus cooperative apartment. Over the next n nights, each of you is supposed to cook dinner for the entire group exactly once, so that someone different cooks on each night. Due to scheduling constraints (concerts, sports, etc), each person is unable to cook on certain nights, so deciding on who is cooking on each night appears to be a tricky task. Suppose we label the people in the flat {p 1 , p 2 ,... , pn} and the nights {d 1 , d 2 ,... , dn}. Then for each person pi, there is a set of nights Si โІ {d 1 , d 2 ,... , dn} where pi is unable to cook. A feasible dinner schedule is an assignment of each person in the flat to a different night, so that each person cooks on exactly one night, there is someone cooking on each night, and if pi cooks on night dj then dj 6 โˆˆ Sj. Describe an algorithm to determine if there is a feasible dinner schedule or not. What is the running time of your procedure?

Solution: Based on the description of the problem, I hope you con- cluded that this is an instance of a matching problem. (If so, youโ€™re correct.) What would you do? You can first build a bipartite graph. The two sets of vertices are taken to be the set of people, and the set of nights. If a person pi is able to cook dinner on a night dj , then you add the edge (pi, dj ) to the bipartite graph. Once you build this bipartite graph, then you can use a maximum flow algorithm to find a maximum matching in the way we talked about in class. Direct all edges from โ€œpeopleโ€ to โ€œnightsโ€, add a source vertex s, with edges from s to each person, and a sink t with edges from each night to t. Set the capacity of each edge to be equal to one. Then find a maximum flow. Thereโ€™s a feasible dinner schedule if and only if there is a maximum flow with value n. Otherwise there is no feasible dinner schedule. If thereโ€™s a maximum flow with value n, then examine the edges in the maximum flow that are used that join people to nights. There will be exactly n of these edges, and due to the way that the graph was constructed (i.e. the fact that all capacities were equal to 1), each person will be joined to a different night, and that gives your feasible dinner schedule. Constructing the bipartite graph takes time at most O(n^2 ) (thereโ€™s at most n^2 edges in the bipartite graph as each of the n people can be joined to at most n nights). Adding the additional edges to make the directed flow network takes time O(n). The Edmonds-Karp maximum flow algorithm takes time at most O(n^3 ). (Using the crude upper bound of n^2 here on the number of edges in the bipartite graph, it could be better.) So overall, finding a feasible dinner schedule, or concluding there isnโ€™t one can be done in time O(n^3 ).

  1. Suppose you are given a flow network with unit capacity edges, i.e. you have a directed graph G = (V, E), a source vertex s and a sink vertex t, and each edge has capacity 1. You are also given an integer parameter k. Your goal is to delete a set of k edges from G in order to reduce the maximum s-t flow as much as possible. In other words, you want to find a subset of edges F โІ E consisting of exactly k edges to delete from G, giving a new flow network Gโ€ฒ, and the maximum s-t flow in Gโ€ฒ^ is as small as possible. Describe an efficient algorithm for performing this task.

Solution: First find a maximum flow in G. This also allows you to find a minimum cut (A, B) where s โˆˆ A and t โˆˆ B. (As has been outlined before in class, consider the residual network associated