


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Algorithms 9007 Tutorial questions 2019 Semester 1 Tutorial 9
The University of Sydney School of Computer Science
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.
(a) What is a bipartite matching? (b) How can one use ow networks to nd a maximum bipartite matching? (c) What does the marriage theorem state?
(a) What does it mean that two paths in a graph are edge disjoint? (b) How can one use ow networks to count the maximum number of edge disjoint paths?
(a) What is ow networks with node supplies and demands? (b) What is a circulation in a network with supplies and demands? (c) How can one use ow networks to model supply and demand?
Problem 1 Suppose you're in charge of managing a eet of airplanes and you'd like to create a ight schedule for them. Here's a very simple model for this. Your market research has identi ed a set of m particular ight segments that that would be very lucrative if you could serve them; ight segment j is speci ed by four parameters: its origin airport, its destination airport, its departure time, and its arrival time. An example of six ights segments you'd like to serve with your planes over the course of a single day may include:
It is possible to use a single plane for a ight segment i, and then later for ight segment j, provided that:
For the example above you can group ights 1, 3, and 5 together by allocating an hour maintaince between each ight and adding an additional 1 hour ight between Cairns and Townsville for example. Your goal based on the two conditions stated above is to determine if it is possible to service all m ights using at most k planes. In order to do this you will need to reuse planes as efficiently as possible.
Solution: The solution is based on the following idea. Units of ow will correspond to airplanes. We will have an edge for each ight, and upper and lower capacity bounds of 1 on these edges to require that exactly one unit of ow crosses this edge. In other words, each ight must be served by one of the places. If (ui; vi) is the edge representing ight i, and (uj ; vj ) is the edge representing ight j, and ight j is reachable from ight i, then we will have an edge from vi to ui with capacity 1. For the example above we get the following s − t capacitated network where it is possible to achieve a ow of 2. Although we use max ow this problem is a minimisation problem in the sense that the aim is to nd the minimum max ow for the following graph where all the edges that are solid are 1.
s
t
Problem 2 Given an undirected graph G = (V; E) and edge capacities c : E → R+ and two vertices s and t, design an algorithm for computing a minimum capacity s-t cut.
Solution: Note that the graph is undirected, so we cannot compute a max- ow using the Ford-Fulkerson algorithm, which expects a directed graph as input. Construct a new directed graph G′^ = (V; E′) with capacities c′^ where for each edge (u; v) ∈ E we create two antiparallel edges (u; v) and (v; u) and set c′(u; v) = c′(v; u) = c(u; v). It's easy to argue that for any cut (A; B) we have c(A; B) = c′(A; B). Thus the min s-t cut with respect to G′^ and c′^ is also a minimum with respect to G and c.
Problem 3 We de ne a new version of the game Capture the Flag. The game is played in a maze that consists of a large number of rooms that are connected by doors. Each door connects two rooms. Each player starts in a given room in the maze (different players may start in different rooms). From each room a player can decide to move to any adjacent room, going through a door, as long as the door is open. All doors are open in the
long. Luckily, a variant of the algorithm can be shown to run for at most O(m log C) iterations. The idea is very simple: Select an augmenting path maximizing the minimum residual capacity along the path. Show how to modify Dijkstra's algorithm to nd such a path in the residual graph Gf^.
Solution: (Sketch.) Recall that Dijkstra's algorithm computes a tentative distance value from s to every vertex in V ; let us denote this tentative distance d[u]. Initially d[s] = 0 and d[u] = +∞ for all other vertices u. The algorithm builds a priority queue for V so that the priority of u ∈ V is d[u]. In each iteration it extracts the vertex u with minimum priority and updates the priority of each neighbor v of u by setting d[v] = min{d[v]; d[u] + ℓ(u; v)}. The tricky part of the analysis is to show that when we remove a vertex u the shortest path distance from s to u equals d[u]. Let us denote the residual capacity of an edge e with ~c(e). In our modi ed version we again keep a tentative value T [u] for each vertex. Initially T [s] = ∞ and T [u] = 0 for all vertices u ∈ V − s. We build a priority queue for V so that the priority of u ∈ V is T [u]. In each iteration we extract the vertex u with maximum priority and update the priority of each neighbor v of u by setting T [v] = max{T [v]; min{T [u]; ~c(u; v)}}. The trick of the analysis is to show that when we remove u from the priority queue the best bottleneck residual capacity to go from s to u equals T [u]. The argument is very similar to the one used for Dijkstra's algorithm, so I'll leave it up to you to ll in the details.