Datenstrukturen & Algorithmen Solution of Sheet 11 FS 14

Similar documents
Exam Datenstrukturen und Algorithmen D-INFK

Exam Datenstrukturen und Algorithmen D-INFK

Exam Datenstrukturen und Algorithmen D-INFK

Exam Datenstrukturen und Algorithmen D-INFK

Chapter 5 Graph Algorithms Algorithm Theory WS 2012/13 Fabian Kuhn

Jessica Su (some parts copied from CLRS / last quarter s notes)

Maximum flows & Maximum Matchings

Lecture 3: Graphs and flows

Lecture 11: Maximum flow and minimum cut

Tutorial for Algorithm s Theory Problem Set 5. January 17, 2013

Graphs and Network Flows IE411. Lecture 13. Dr. Ted Ralphs

Graph Algorithms Matching

Theorem 3.1 (Berge) A matching M in G is maximum if and only if there is no M- augmenting path.

Minimum Cost Edge Disjoint Paths

and 6.855J March 6, Maximum Flows 2

Datenstrukturen und Algorithmen

Matching Algorithms. Proof. If a bipartite graph has a perfect matching, then it is easy to see that the right hand side is a necessary condition.

CS612 Algorithms for Electronic Design Automation

Datenstrukturen & Algorithmen Blatt P13 HS 18

Assignment 1 Introduction to Graph Theory CO342

Network Flow and Matching

Graph theory. Po-Shen Loh. June We begin by collecting some basic facts which can be proved via bare-hands techniques.

Matching. Algorithms and Networks

Homework 3 Solutions

Solving problems on graph algorithms

CS261: Problem Set #1

6. Lecture notes on matroid intersection

Exam problems for the course Combinatorial Optimization I (DM208)

Lecture 14: Linear Programming II

Assignment 4 Solutions of graph problems

Graph Algorithms (part 3 of CSC 282),

COMP260 Spring 2014 Notes: February 4th

CPSC 536N: Randomized Algorithms Term 2. Lecture 10

An Eternal Domination Problem in Grids

Network Design and Optimization course

CSE 417 Network Flows (pt 2) Modeling with Max Flow

Bipartite Matching & the Hungarian Method

1 Matchings in Graphs

CSE 417 Network Flows (pt 3) Modeling with Min Cuts

Network Flow. November 23, CMPE 250 Graphs- Network Flow November 23, / 31

Solutions for the Exam 6 January 2014

Advanced Methods in Algorithms HW 5

Notes for Lecture 20

LECTURES 3 and 4: Flows and Matchings

GRAPH DECOMPOSITION BASED ON DEGREE CONSTRAINTS. March 3, 2016

Adjacent: Two distinct vertices u, v are adjacent if there is an edge with ends u, v. In this case we let uv denote such an edge.

1 Bipartite maximum matching

PERFECT MATCHING THE CENTRALIZED DEPLOYMENT MOBILE SENSORS THE PROBLEM SECOND PART: WIRELESS NETWORKS 2.B. SENSOR NETWORKS OF MOBILE SENSORS

Mathematics Masters Examination

Maximum Flow. Flow Networks. Flow Networks Ford-Fulkerson Method Edmonds-Karp Algorithm Push-Relabel Algorithms. Example Flow Network

5. Lecture notes on matroid intersection

Matchings. Saad Mneimneh

GRAPH THEORY and APPLICATIONS. Matchings

Source. Sink. Chapter 10: Iterative Programming Maximum Flow Problem. CmSc250 Intro to Algorithms

Network flows and Menger s theorem

1. Lecture notes on bipartite matching February 4th,

SURIEM 2016 Final Report: Games on Graphs

implementing the breadth-first search algorithm implementing the depth-first search algorithm

Copyright 2007 Pearson Addison-Wesley. All rights reserved. A. Levitin Introduction to the Design & Analysis of Algorithms, 2 nd ed., Ch.

Zhibin Huang 07. Juni Zufällige Graphen

Introduction to Graph Theory

Matching 4/21/2016. Bipartite Matching. 3330: Algorithms. First Try. Maximum Matching. Key Questions. Existence of Perfect Matching

1 Matching in Non-Bipartite Graphs

UML CS Algorithms Qualifying Exam Spring, 2004 ALGORITHMS QUALIFYING EXAM

Figure 2.1: A bipartite graph.

Counting the Number of Eulerian Orientations

Datenstrukturen & Algorithmen Blatt P7 HS 18

Combinatorics MAP363 Sheet 1. Mark: /10. Name. Number. Hand in by 19th February. date marked: / /2007

Part II. Graph Theory. Year

Artificial Intelligence

CSC 8301 Design & Analysis of Algorithms: Linear Programming

On the Balanced Case of the Brualdi-Shen Conjecture on 4-Cycle Decompositions of Eulerian Bipartite Tournaments

Graphs. Edges may be directed (from u to v) or undirected. Undirected edge eqvt to pair of directed edges

On Covering a Graph Optimally with Induced Subgraphs

Finding a -regular Supergraph of Minimum Order

Minimum Spanning Trees My T. UF

Graphs and Network Flows IE411. Lecture 21. Dr. Ted Ralphs

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/18/14

Treewidth and graph minors

Graph theory - solutions to problem set 1

Graph Algorithms Maximum Flow Applications

Extremal Graph Theory. Ajit A. Diwan Department of Computer Science and Engineering, I. I. T. Bombay.

CS6382 Theory of Computation. Spring Homework #3

CMPSCI 311: Introduction to Algorithms Practice Final Exam

AMS /672: Graph Theory Homework Problems - Week V. Problems to be handed in on Wednesday, March 2: 6, 8, 9, 11, 12.

Algorithms for Graph Visualization Layered Layout

Graph Algorithms (part 3 of CSC 282),

Math 443/543 Graph Theory Notes 5: Planar graphs and coloring

DO NOT RE-DISTRIBUTE THIS SOLUTION FILE

Clustering Using Graph Connectivity

The Matrix-Tree Theorem and Its Applications to Complete and Complete Bipartite Graphs

5 Graphs

Solution for Homework set 3

COT 6936: Topics in Algorithms! Giri Narasimhan. ECS 254A / EC 2443; Phone: x3748

Answers to specimen paper questions. Most of the answers below go into rather more detail than is really needed. Please let me know of any mistakes.

4. (a) Draw the Petersen graph. (b) Use Kuratowski s teorem to prove that the Petersen graph is non-planar.

MATH 350 GRAPH THEORY & COMBINATORICS. Contents

Problem Set 7 Solutions

Graph Theory: Matchings and Factors

Matching and Planarity

Transcription:

Eidgenössische Technische Hochschule Zürich Ecole polytechnique fédérale de Zurich Politecnico federale di Zurigo Federal Institute of Technology at Zurich Institut für Theoretische Informatik 14th May 2014 Peter Widmayer Tobias Pröger Datenstrukturen & Algorithmen Solution of Sheet 11 FS 14 Solution 11.1 Max-Flow by Hand. The value of a maximum flow is 31. A maximum flow is shown in the following figure. Next to each edge e, the capacity c e and the flow value x e are denoted in the order x e, c e. The minimum cut is indicated by the dotted line, the belonging edges are bold. The following figure shows the residual graph for the previous flow. Each edge is labeled with its residual capacity (c e x e oder x e ). Solution 11.2 Championship Problem. Imagine that FCL wins both remaining games against FCZ and GCZ having enough goals. Then FCL has 37 points. To win the championship, FCSG may not receive any additional points, YB at most one, FCB at most two, and FCW at most six. The central observation for the construction of the network is that exactly two points are divided in each of the remaining games: if there is a winner, he receives both points; in the case of a tie each participant gets exactly one point. Thus, for each of the games FCSG-FCB, YB-FCW, FCW-FCSG, and FCB-YB we create a node in the network with an incoming edge from a source s and two outgoing edges to the corresponding

participants of the game. Each of these edges has a capacity of 2. From each participant, we generate an edge to a sink t and set the capacity to the maximum number of points such that FCL still wins the championship. This leads to the following network. FCL can only win the championship if there exists a flow of value 8 in the above network, because in each of the four remaining games, two points are spread among the corresponding participants. The max-flow min-cut theorem states that the value of a maximum flow is bounded by the value of a minimum cut. In the above network, there exists the following cut of value 7: For this reason, no flow of value 8 exists. Thus, FCL cannot win the championship no matter how high they win both the remaining games. Solution 11.3 Evacuation Problems. a) Let G = (V G, E G ) be the undirected grid given as input. The vertex set V of the network N contains every vertex from G, and additionally, a dedicated source s and a dedicated target t. The edge set of N contains the following edges: For every starting vertex s i, N contains the edge (s, s i ). For every (undirected) edge {v, w} E G of the grid, N contains the two directed edges (v, w) and (w, v). For every boundary vertex r j, N contains the edge (r j, t). Thus we construct a network N = (V, E, c) with V := V G {s} {t} (1) E := {(s, s i ) i {1,..., m}} {(v, w), (w, v) {v, w} E G } (2) {(r j, t) r j is a boundary vertex of G} 2

c((s, s i )) := 1 i {1,..., m} (3) c((v, w)) := 1 {v, w} E G (4) c((r j, t)) := 2 boundary vertices r j (5) Notice that a boundary vertex may be used twice. On one hand it can be the last vertex of an escape route that starts in the interior of the grid. On the other hand there might be an escape route that consists of exactly this boundary vertex. For this reason the capacity of the edges (r j, t) has to be set to 2 (instead of 1). In G there exist m edge-disjoint escape routes if and only if there exists a flow of value at least m in the above network N. b) We first analyse the size of the grid in dependency of n. The grid G has V G = n 2 many vertices, thus we have V = 2 + V G Θ(n 2 ). Furthermore G has exactly E G = 2n(n 1) 2n 2 many edges and 2n+2(n 2) = 4n 4 many boundary vertices. Since every edge of G occurs twice in N, we have E = m + 2 E G + 4n 4 n 2 + 4n 2 + 4n Θ(n 2 ). The value of the flow is bounded by m (the number of starting vertices) as well as by 8n 8, since there exist only 4n 4 boundary vertices and as stated above, only two escape routes can end in a common boundary vertex (in theory more escape routes might be possible, but every additional one visits at least one more boundary vertex and thus doesn t need to be considered). There exist different flow algorithms to solve this problem. For example, the algorithm of Ford and Fulkerson computes a maximum flow with O( E φ ) operations where φ is is value of the maximum flow. Therefore its running time is pseudo-polynomial, and in general there exist more efficient methods for flow maximization. However, we have both E Θ(n 2 ) as well as φ = min{m, 8n 8} Θ(min{m, n}). Thus the running time of Ford and Fulkerson s algorithm is only O(n 2 min{m, n}), and it is optimal in this particular case. c) Let v V G be a vertex of the grid and Γ(v) = {w V G {v, w} E G } be the set of all neighboring vertices of v in G. In the network N, for each vertex v V G we create two vertices v in and v out that are connected by the edge (v in, v out ). Apart from this edge, v in contains only incoming and v out only outgoing edges. For every neighbor w Γ(v) we create the edges (v out, w in ) and (w out, v in ). 3

For every starting vertex s i we create an edge (s, s in i ). Additionally for every boundary vertex r j we create an edge (rj out, t) leading to the target t. We assign capacity 1 to every edge. In comparison to a) we nearly have twice the number of vertices (only the source and the target are not doubled). For each vertex v V G we only create one additional edge, namely the inner edge (v in, v out ). Thus we have V Θ(n 2 ) and E Θ(n 2 ) as before, and the running time does not change. Solution 11.4 Matchings. a) Let M be a matching of maximum cardinality and M be an arbitrary maximal matching. By definition, M has maximum cardinality, thus we immediately obtain M M. To prove M 2 M we assume w.l.o.g. that we have M = {e 1,..., e k } with edges e i = {v i, w i } for every i, 1 i k. For every maximal matching M and every i, 1 i k, there must exist an edge e M that is incident to v i, to w i, or to both (if such an edge would not exist, then e i = {v i, w i } could be added to M, and M would not be maximal). Since every edge is incident to exactly two vertices, M must contain at least k/2 edges, thus we have M k/2 = M /2 M 2 M. b) In the following graph, M = {{a, e}, {b, f}, {c, g}, {d, h} is a matching with maximum cardinality while M = {{a, f}, {c, h}} is a maximal matching. c) This task can be solved by the following very simple greedy algorithm: MaximalMatching(G) Input: Undirected Graph G = (V, E) Output: Maximal matching M E 1 M 2 while G contains at least one edge do 3 Select an arbitrary edge e from G. 4 M M {e} 5 Remove all edges from G that have at least one vertex with e in common. 6 return M Although the correctness is obvious, we prove it for the sake of completeness. We first show that M is a matching at every step of the algorithm. Suppose that this was not the case. Then M contained two edges e and e with a common vertex. Suppose that e was the first edge considered by the algorithm. Then, e would have been removed from G in step 5. The same argument can be applied if e was the first edge selected. It remains to show that M is maximal after the algorithm terminates. Suppose that M was not maximal. Then there was some edge e M such that M {e } is a matching. Since e was not selected by the algorithm, it was previously removed in step 5. However this only happens if there exists some edge e M that shares a common vertex with e. Thus, M {e } would not be a matching. 4

It is easy to see that the algorithm can be implemented to run in time O( E ) if the graph is stored as an adjacency matrix and additionally all edges are stored in a doubly-linked list L. Every edge e = {v, w} from L is additionally doubly-linked with the corresponding entries in the adjacency lists of v and w. Then the steps 1, 3 and 4 and the test in step 2 whether the graph contains at least one edge can be performed in time O(1). Furthermore every edge is being considered only once and removed directly after that; since the removal is possible in time O(1), we obtain an overall running time of O( E ). Notice: If only an adjacency list representation of G is given, then L can be computed from G in time O( V + E ) by iterating over all adjacency lists of G and adding the corresponding edges to L. d) Halls s theorem states that there is no perfect matching in a bipartite graph if there exists a set M of vertices with Γ(M) < M, where Γ(M) is the set of neighbors of the vertices in M. In our example, such a set is M = {a, c, e} with Γ(M) = {h, i}. Another possibility is M = {f, g, j} with Γ(M) = {b, d}. By Hall s theorem, each of these sets proves that the graph has no perfect matching. 5