260 likes | 388 Views
Introduction to Graph Theory. Lecture 07: Bipartite Graphs, Matching and Job Assignments. Bipartite Graphs. A graph is bipartite if V(G) is partitioned into nonempty subsets V 1 and V 2 , such that if xy is in E(G), x and y belong to different subsets. r1. w1. r2. w2. r3. w3. r4. r5.
E N D
Introduction to Graph Theory Lecture 07: Bipartite Graphs, Matching and Job Assignments
Bipartite Graphs • A graph is bipartite if V(G) is partitioned into nonempty subsets V1 and V2, such that if xy is in E(G), x and y belong to different subsets. r1 w1 r2 w2 r3 w3 r4 r5
Bipartite Graphs • It is common that each subset is give a color. • Can you think of graphs that we have come across are bipartite? • Paths, Pn • Trees • Cn when n is even. • The cardinality of the color sets is an invariant of a bipartite graph.
Algorithm We want to label V1(G) a and V2(G) b. • Label any vertex a and its neighbors b • If there are unlabeled vertices adjacent to labeled vertex v, label them the opposite label that v was assigned. Repeat until no such vertices • If there is an unlabeled vertex, go back to step 1 with such a vertex • If all adjacent vertices get distinct labels G is bipartite.
Shortcut • Can we do without the algorithm? • If G contains a cycle with odd number of vertices. • Theorem: A graph G is bipartite if and only if G does not contain an odd cycle. • Proof?
Matchings • A matching M is a set of edges, no two of which are incident with one another. • What applications can you think of? • Seat assignment to ensure harmony • Job assignment to maximize efficiency • Anything else? r1 w1 r2 w2 r3 r4 w3 r5
Matchings in Bipartite Graph • Let G be a bipartite graph with parts X and Y. • Complete matching from X to Y: Every vertex in X is incident with an edge of M. (the direction is important, and |X|<|Y|) • Perfect matching: M is complete from X to Y and Y to X. (|X|=|Y|) • Can you think of an application in which the complete matching is important?
Finding Maximum Matching • Maximum matching: M is a maximum matching for G if M has largest cardinality among all possible matchings. • Maximal matching: A matching M that cannot be enlarged by adding additional edges, i.e. no larger M’ containing M. • The goal here is to find a maximum matching
Illustration d d c c e e b b f f a a g g h h (b) Maximum (a) Maximal
More Definitions • M-alternating path: A path in G whose edges are alternately in M and not in M. • A vertex is M-matched if incident to one of the edges of M. Else M-unmatched. • M-augmenting path is an alternating path joining two M-unmatched vertices. • Need not use all the edges of M • Always begin and end with an edge not in M
Finding the Maximum Matching • Berge’s Matching Theorem: A matching M in a graph G is maximum if and only if there is no M-augmenting path in G. • Proof: “if and only if ” demands the proofs for both directions.
Proof (Left -> Right) • Prove by contradiction • Suppose that matching M is maximum, and there is an M-augmenting path P. • P necessarily has one more edge not in M than in M. • Let be edges of P in M, and not in M • We construct a new match • . Contradiction!
Proof (Right -> Left) • Suppose no M-augmenting path, and M is indeed maximum. • Assuming M* is maximum => no M*-aug path • Let’s construct a graph H containing all V(G), and • Analysis of H reveals that • So, M is maximum
Algorithm • For maximum matching in a bipartite graph, we’ll study the algorithm when we discuss networking.
Complete vs. Perfect Matching • What properties of a bipartite graph allow as to conclude if a graph is complete or perfect? • Having even number of vertices? • G is equitable? (parts X and Y have the same number of vertices)
Complete Matching in Bipartite Graph • Some notations: • n(v) is the set of all vertices adjacent to v. • Hall’s Matching Theorem: a bipartite graph G with parts X and Y as a complete matching from X to Y if and only if for every subset
Proof: Forward direction • To prove: If a bipartite graph G with parts X and Y as a complete matching from X to Y then for every subset • Proof: A complete matching implies each vertex in X is matched to a distinct vertex in Y. Therefore, this condition follows.
Proof: Backward direction • To prove: If a bipartite graph G with for every subset then G has a complete matching from X to Y • Proof: By contradiction. • Suppose no complete matching from X to Y. • Let M be the maximum match and is M-unmatched • Using the given condition, we know that v has at least one neighbor in Y.
Proof: Backward direction (cont) • Proof: By contradiction • Case1: if one such neighbor v* is not in Y* (the set of M-matched vertices in Y), then • Case2: if every neighbor v* of v is in Y*, we can start and M-alternating path at v that will become M-aug path, since for every • This implies that M is not maximum (by Berges’s matching theorem)
Perfect Matching in Bipartite Graph • Hall’s Marriage Theorem: a bipartite graph G with parts X and Y, where |X|=|Y|, has a perfect matching if and only if for every subset • Proof?
Perfect Matching • Anther necessary condition for a bipartite graph to be a perfect matching is that it is regular. • We start with a lemma • Lemma: An r-regular bipartite graph must be equitable. • Assume that |X|=k, then |E(G)|=r*k • The r*k edges each is incident with a vertex in Y, since G is bipartite • And each vertex in Y is incident with r of the r*k edges => r|Y|=r*k • Therefore |Y|=k=|X|
Perfect Matching • Theorem: If a bipartite graph is regular, the it has a perfect matching • Proof: • We know that G is |X|=|Y|. So, only need to show that G has a complete matching from X to Y • We want to show that , for every subset in order to apply Hall’s matching theorem. • The technique is similar to the proof for the lemma
(cont) • Proof: • Given any set S of m vertices in X, there is a total of r*m edges, since G is r-reg • Each of the r*m edges are also incident to a vertex in Y, since G is bipartite • Since each vertex in Y is only incident to r edges, N(S) must contain at least m vertices in Y. • Therefore • Combining this with Hall’s theorem and the lemma, we complete the proof.
Some Remarks • M-augmenting path techniques applies to all graphs, not just bipartite graphs. • There are other techniques for finding maximum matchings, e.g. the network flow technique. • Matchings can be found in weighted graphs too.
Quiz • Let T be a spanning tree of G. Show that a perfect matching for T is also a perfect matching for G. Find an example to show that the converse is not true.