


Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!



We define the Escape Problem as follows. We are given a directed graph G = (V, E) (picture a network of roads). A certain collection of nodes X ⊂ V are designated as populated nodes, and a certain other collection S ⊂ V are designated as safe nodes. (Assume that X and S are disjoint.) In case of an emergency, we want evacuation routes from the populated nodes to the safe nodes. A set of evacuation routes is defined as a set of paths in G so that (i) each node in X is the tail of one path, (ii) the last node on each path lies in S, and (iii) the paths do not share any edges. Such a set of paths gives a way for the occupants of the populated nodes to “escape” to S, without overly congesting any edge in G.
(a) Given G, X, and S, show how to decide in polynomial time whether such a set of evacuation routes exists.
(b) Suppose we have the same problem as in (a), but we want to enforce an even stronger version of the “no congestion” condition (iii). Thus, we change (iii) to say “the paths do not share any nodes (except maybe the final one in S).” With this new condition, show how to decide in polynomial time whether such a set of evacuation routes exists.
(c) Provide an example with the same G, X, and S, in which the answer is yes to the question in (a) but no to the question in (b).
Solution:
Figure 1: Red are in X, while blue ones are in S.
(a) Let us build a graph as shown in Figure 1. We add a dummy source node s and edges (s, u) for each node u in X and also a dummy sink t connected with edges (v, t) for each v ∈ S. Then we set a capacity of 1 for any edge in the new graph except for the edges (v, t) that have capacities |X| (we could also use +∞). Observe that, by max-flow min-cut theorem, the maximum flow has always a value less then the cut containing only s (of capacity |X|). We claim that the value of the maximum flow is exactly equal |X| if and only if the problem has a solution. 1) If the problem has a solution, there exist edge-disconnected paths Pu connecting each u ∈ X to a node in S. Let us set fe = 1 for each edge e in all paths Pus and for all edges (s, u). This configuration respects flow conservation since the paths are edge-disjoint. We set f (v, t) for v ∈ S to respect flow conservation. This flow has maximum value by the observation above. 2)Now for the other direction, assume that the flow has value X. We can assume as well that the flow is integral, i.e. it has binary values except at the edges connecting to the sink. Since the capacities are 1 on the edges from the source, this means that the flow saturates them i.e. f (s, u) = 1 for all u ∈ X. By flow conservation, for each u ∈ X, there exists a w such that f (u, w) = 1. Bulding a path in this way, we eventually reach set S and then t. By conservation, the paths built in this way have to be edge disjoint, since the capacities are all 1 (before reaching S).
(b) In this case, we construct a graph G′^ = (V ′, E′) in the following way. We create a duplicate w′^ for each node w ∈ V \ {S ∪ X} and insert an edge (w, w′) with capacity 1. Then every edge directed towards w in G stays the same in G′, while every edge (w, v) ∈ E is substituted by an edge (w′, v) ∈ E′. The procedure is depicted in Figure 2. Then we add source and sink and capacities exactly as in the previous case. G′^ will have 2 n − |S| − |X| + 2 nodes and m + n edges. It can be shown again, that the value of the maximum flow is exactly equal |X| if and only if the problem has a solution. The proof is very similar to point (a) and left to the reader.
(c) The graph depicted in Figure 1 is such an example.
Figure 2: The construction explained in (b).
Let G = (V, E) be a directed graph and for every edge e ∈ E let c(e) ∈ N be its integer non-negative capacity. Let s, t ∈ V be a source and a sink node and let f : E −→ N be a max flow from s to t which is acyclic, i.e., there is no cycle in G in which all edges have positive flow. Suppose the capacity of one specific edge e′^ ∈ E decreases of one unit, i.e., consider the new capacities:
c′(e) = c(e) − 1 for e = e′ c′(e) = c(e) for e ̸= e′
Design an algorithm that, starting from f , finds a max flow from s to t in the graph G with the new capacities c′^ in time O(|V | + |E|).
Solution: We can assume f to be integral. First we observe that, if e′^ is not saturated (i.e. f (e′) ̸= c(e′) then f remains a max flow after chaning capacities. Assume that e′^ is saturated, instead. Let f ′^ ≡ f where f ′(e′) = c′(e′). Clearly, f ′^ does not satisfy the capacity conditions. The idea is to adjust it in order to satisfy them. Since f is acyclic there exist unique paths Psv and Pwt carrying positive flow. Then a BFS or DFS can find such paths in O(|V | + |E|) time. We diminish f ′^ on both paths by 1 on each edge, and in this way f ′ satisfies the capacity constraints. Now, f ′^ has exactly the value of f minus 1. At this point we can run one step of the Ford-Fulkerson algorithm, starting by f ′. If we consider Gf ′ there are two possibilities: either there exists an augmenting path and then this step increases its value of at least 1 (thus we reach a maximum flow) or it does not, meaning that f ′^ is already the max flow for the modified network.
Consider a city with m parallel horizontal streets and n parallel vertical avenues. These lines cross in m × n intersections. On k ∈ { 1 ,... , m × n} of these intersections, special checkpoints are placed. The situation is depicted in Figure 3. We want to place video cameras on a subset of the streets and of the avenues such that each checkpoint is in the visibility range of a camera. A camera allows to monitor all the checkpoints of an avenue or of a street. The subset may contain both horizontal streets and vertical avenues. Clearly, you can always select all m + n of these streets and avenues. The challenge therefore is to select a smallest subset of these streets and avenues such that each checkpoint is in the visibility range of a camera. Give an algorithm that finds such a smallest subset of streets and avenues where to place cameras in time polynomial in m and n. Prove that the algorithm is correct and provide an analysis of its running time.
Figure 3: Grid city as described in Problem 3. Black dots represent checkpoints.
Solution: Let us call R the set of streets (rows) and C the set of avenues (columns) that contain at least a checkpoint. We build a graph G in the following way: we set V to be R ∪ C and (r, c) ∈ E if and only if a checkpoint is at the intersection of r and c. In particular, this means that |E| = k and that the graph is bipartite. This graph is shown in Figure 4 We add a source s connected with an outgoing edge with all the streets in V and a sink t connected with all avenues with edges directed to t. Let us set all the capacities of edges from s and to t to be 1 and the others +∞. In this way, we know that the max-flow for G corresponds to
(i) For a given parameter c, each doctor should be assigned to work at most c vacation days total, and only days when he or she is available.
(ii) For each vacation period j, each doctor should be assigned to work at most one of the days in the set Dj. (In other words, although a particular doctor may work on several vacation days over the course of a year, he or she should not be assigned to work two or more days of the Thanksgiving weekend, or two or more days of the July 4th weekend, etc.)
The algorithm should either return an assignment of doctors satisfying these constraints or report (correctly) that no such assignment exists. Solution: You can read the solution on the book to see how to contruct the network for this problem. Notice that, in such solution, a demand of +d on the sink and one of −d on the source is utilized. Then, the existence of a feasible circulation is equivalent to the existence of a solution to the initial problem. Equivalently, one can use the same network without those demands, and the condition becomes that the value of a max-flow is exactly |D| i.e. the total number of vacation days in the year.