Lecture3
Upcoming SlideShare
Loading in...5
×
 

Lecture3

on

  • 94 views

 

Statistics

Views

Total Views
94
Views on SlideShare
94
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Lecture3 Lecture3 Document Transcript

  • 2WO08: Graphs and Algorithms Instructor: Nikhil Bansal 1 Lecture 3 Date: 14/2/2012 Scribe: Ellen Dibbits Halls’ Theorem In the second lecture Halls’ Theorem is discussed, this lecture we started with proving it again in another way. Theorem 1 Halls’ Theorem Given a bipartite graph, there is a perfect matching iff |N (s)| ≥ |S| ∀ S ⊆ X, where X is one of the sets of points of the graph. Proof: This proof is with induction. We take n the amount of vertices in X. For n = 1 it is trivial, because we just have one vertex in each part, so we can match those vertices with one edge. And S is empty or contains one point, and in both cases is the amount of neighbors the same. Now we assume that the statement is true for all graphs on k vertices in X. We want to prove that it is also true for k + 1 vertices in X. Take vertex v in X, then there is at least one edge leaving v otherwise there won’t be a perfect matching possible at all. Now we consider two cases. Case 1: Suppose ∀ S ⊆ X − {v} : |N (S)| ≥ |S| + 1. In this case we have slack so we can match v with that one edge and then there is still a perfect matching for the other vertices, because we then have a graph of size k where |N (S)| ≥ |S| holds, and we assumed then the statement is true. The +1 dissapears because we’ve matched v to some vertex and in the worst case that was a neighbor of all other vertices in X as well. So in this case we’ve proven we have a perfect matching. Case 2: So in this case there exists some subset S ⊆ X − v such that |N (S)| = |S|. Pick a minimum cardinality set satisfying this property. By induction and the minimality of S, we know that S can be matched to N (S) Now look at X − S, for this specific S, take a set S ⊆ X − S. Then this S needs to have neighbors outside N (S), otherwise S ∪ S doesn’t suffice the Hall’s condition. Note that it has to have |S | outside N (S). If we then look at the rest, by induction also those points have a matching in Y − N (S). So combining this matchings we have a full matching. This proves the statement. 2 We will now continue with some examples where it is possible to use Halls’ Theorem. Example 1 If you have n teachers and n courses you can see this as a bipartite graph. Every teacher can teach a few courses and you want a teacher assigned to each course. This you can solve with a matching. Example 2 We have a usual deck of 52 cards. Divide this deck into 13 arbitrary piles of 4 cards. Prove that it is always possible to get exactly the set A, 2, 3, ..., J, Q, K by picking one card from each pile. We can transform this problem into a bipartite graph. On one side 13 vertices representing the piles and on the other side 13 vertices, one for A, one for 2, etc. Notice that each vertex has degree four and that we want a perfect matching. Take a set S, a subset of the piles, 4∗|S| edges are leaving of this set, but the receiving vertices have also degree four so |N (S)| ≥ number 4 edges = 4|S| = |S|, 4 otherwise there is a vertex with degree greater than 4. So by Halls’ Theorem a perfect matching exists. 1
  • Note that we can also decompose all cards into 4 sets, such that each set contains exactly one card from each pile, and contains exactly a single A, 2, 3, ..., J, Q, K. This can be seen by after getting that set, remove the edges from the graph and then use the same argument with the degree one less. Example 3 Dancing Problem Consider a group of n boys and n girls where everyone knows exactly k people of the other gender. It is possible to make a dance scheme of k rounds where everyone will dance exactly once with each of the people they know. This can be seen with a matching. Example 4 Scheduling tasks We want to schedule n tasks among m machines. Every task j has size pj and our goal is to minimize the total completion time of all jobs, where the total completion time equals the sum of the completion times. This is useful as it is equivalent to computing the average waiting time. To solve this problem we make the following crucial observation. Consider some machine, if job i is the k-th last job to be assigned to it, then it contributes exactly kpi to total completion time (this is because it contributes pi to its own completion time, and to each of the jobs that are place after it). We will construct a bipartite graph where on one side there are n vertices representing the jobs and on the other side we will mn vertices, where there are n vertices of the type (m, j) for each machine m. The vertex (m, 1) represents the last job on machine m, (m, 2) the second last job on machine m, etc. Note that we do not want a perfect matching in this case because we don’t want to match all mn vertices representing the machines. The edge costs will be determined in the following way, for an edge from j to (m, i) the cost will be pj ∗ i. Then the problem can be solved by finding a minimum cost maximal matching. 2 Maximum Flows You should have seen max-flow in your previous courses, so this will be quick recap. A definition can be found on page 145 of [2]. The capacity of an edge e we will denote with ce , and we want to find a maximum flow from s to t. Max-flow can be used to model various problems. Transforming the matching problem on a bipartite graph into a maximum flow problem can be done with adding a source and a sink. On one side you will add the source, s, and join this with all vertices of one side of the bipartite graph, those edges go from s to the original graph. On the other side you’ll add a sink, t, which will be joined with all vertices on the other side of the bipartite graph, here the edges will go from the original graph to t. All extra edges will have capacity one. All edges from the already existing graph will have capacity infinity, unless stated otherwise. As recap we discussed the maximum flow-minimum cut theorem, which can be found on page 149 of [2]. We discussed a proof of this theorem using residual graphs. To find the maximum flow in a graph there exist efficient algorithms. The naive algorithm that simple augments flow along a path a residual graph can perform very poorly. Two useful ones are the Maximum augmenting path algorithm (O(min(m2 log nlog(C), mn2 log C)) where C is the maximum capacity) and the shortest length path (O(mn2 )). The first one is a simple algorithm, the second is a bit more complex. A nice readable description of these can be found in the notes that are linked on the course webpage. 2
  • There are also other algorithms known with improved running times. We will now start with a new theorem but first we need a definition. Definition 2 Vertex Cover A subset of vertices such that ∀ edges at least one endpoint is in this subset. Theorem 3 Konig-Egervary In a bipartite graph the size of a minimum vertex cover equals the size of the maximum matching. Corollary 4 The maximal independent set1 in a bipartite graph can be found in polynomial time. Proof of [.Konig-Egervary] • For proving that the size of the minimum vertex cover is greater or equal than the size of the maximum matching, we first notice that the size of any vertex cover must be at least the size of any matching. To see this, consider some matching M , clearly at least one endpoint of each edge must lie in every vertex cover (otherwise this will not be covered). Picking M to be a maximum size matching, the claim follows. • To prove the other direction, we know that any flow in the network corresponding to the bipartite graph (mentioned earlier) gives a matching. So the maximum can be no smaller than the maximum flow. Consider the min-cut corresponding to this maximum flow. his cut splits S and T , where S is the part containing s and T the part containing t. We notice that the minimum cut cannot cross edges with capacity infinity going from S to T , because the cut where S = {s} is smaller in that case. By drawing a picture, and noting that no infinite capacity edges are cut, we see that the size of the minimum cut equals |L ∩ T | + |R ∩ S|, where L are the vertices of the bipartite graph connected with s and R the ones connected with t. We also note that that |L ∩ T | + |R ∩ S| is a vertex cover because there are no edges form |L ∩ S| to |R ∩ T | because the cut is not of infinite size. So now we know there is a vertex cover equal to this minimum cut. So the minimum vertex cover can only be smaller that this minimum cut. As the maximum matching is not smaller than the minimum cut, this implies the other direction. Those points together conclude that indeed the size of the minimum vertex cover in a bipartite graph equals the size of the maximal matching in the same graph. 2 3 Menger’s Theorem There are several versions of Menger’s Theorem, we will discuss a few here. But first we will state a few definitions. Definition 5 Paths are said to be edge disjoint if they share no edges. Definition 6 s-t-paths are said to be vertex disjoint if they share no vertices other then s and t. 1 see [1] 3
  • Theorem 7 Menger’s Theorem for directed graphs, edgedisjoint case Consider a directed graph. Then the maximum number of edge disjoint s-t-paths equals the minimum number of edges needed to disconnect s and t. For proving this, the ’≤’ one is quite obvious, because every path has to go through one of those edges. The other side follows by giving each edge a capacity of one and using the max-flow-min-cut theorem. Theorem 8 Menger’s Theorem for directed graphs, vertexdisjoint case Consider a directed graph. Then the maximum number of vertex disjoint s-t-paths equals the minimum number of vertices needed to disconnect s and t. Here also the proof is obvious one way and a bit harder the other way. Since, min-cut deals with edges, while we want a statement about vertices, we transform a vertex into an edge as follows. Consider vertex v, and replace it by two vertices v1 and v2 connected by an edge from v1 to v2 of capacity 1. All incoming edges will now go into v1 and all outgoing edges will now leave v2 (so an original edge (v, w) now becomes (v2 , w1 )). The original edges have capacity ∞. You can then again see it as a max-flow problem, where the size of the maximal flow equals the number of vertex disjoint paths and size of the minimum cut. Several proofs of Menger’s Theorem can be found in Chapter 3 of [2]. References [1] http://en.wikipedia.org/wiki/Independent set [2] Reinhard Diestel. Graph Theory, fourth electronic edition, 2010. 4