Algorithms. Definition: An algorithm is a set of rules followed to solve a problem. In general, an algorithm has the steps:

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

1 Matchings in Graphs

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.

MC302 GRAPH THEORY SOLUTIONS TO HOMEWORK #1 9/19/13 68 points + 6 extra credit points

MTL 776: Graph Algorithms Lecture : Matching in Graphs

5 Matchings in Bipartite Graphs and Their Applications

1. Lecture notes on bipartite matching

2. Lecture notes on non-bipartite matching

MATH 682 Notes Combinatorics and Graph Theory II

What is the sum of the measures of the angles of a quadrilateral?

CSE 417: Algorithms and Computational Complexity

Advanced Combinatorial Optimization September 17, Lecture 3. Sketch some results regarding ear-decompositions and factor-critical graphs.

Perfect matchings in O(nlogn) time in regular bipartite graph

Matchings. Examples. K n,m, K n, Petersen graph, Q k ; graphs without perfect matching. A maximal matching cannot be enlarged by adding another edge.

CISC 320 Introduction to Algorithms Fall Lecture 15 Depth First Search

COMP260 Spring 2014 Notes: February 4th

Matching Theory. Figure 1: Is this graph bipartite?

Spanning Trees. CSE373: Data Structures & Algorithms Lecture 17: Minimum Spanning Trees. Motivation. Observations. Spanning tree via DFS

Ma/CS 6b Class 2: Matchings

Matching in Bipartite Graphs

1 Matching in Non-Bipartite Graphs

Lecture 4: Primal Dual Matching Algorithm and Non-Bipartite Matching. 1 Primal/Dual Algorithm for weighted matchings in Bipartite Graphs

Math 170- Graph Theory Notes

MC302 GRAPH THEORY Thursday, 10/24/13

Homework 3 Solutions

Minimum Spanning Trees

Solution for Homework set 3

Computational Geometry

Figure 2.1: A bipartite graph.

Problem Set 2 Solutions

CSE 332: Data Structures & Parallelism Lecture 22: Minimum Spanning Trees. Ruth Anderson Winter 2018

5 Graphs

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

2 The Fractional Chromatic Gap

Lecture 11a: Maximum Matchings Lale Özkahya

Advanced Combinatorial Optimization September 15, Lecture 2

Analysis of Algorithms Prof. Karen Daniels

Lecture 13: Weighted Shortest Paths. These slides include material originally prepared by Dr. Ron Cytron and Dr. Steve Cole.

MATH20902: Discrete Maths, Solutions to Problem Set 1. These solutions, as well as the corresponding problems, are available at

K 4 C 5. Figure 4.5: Some well known family of graphs

11.1. Definitions. 11. Domination in Graphs

Graph theory - solutions to problem set 1

Lesson 4.2. Critical Paths

8 Matroid Intersection

Mathematical and Algorithmic Foundations Linear Programming and Matchings

1. Lecture notes on bipartite matching February 4th,

Abstract. A graph G is perfect if for every induced subgraph H of G, the chromatic number of H is equal to the size of the largest clique of H.

6. Lecture notes on matroid intersection

6c Lecture 3 & 4: April 8 & 10, 2014

The Dynamic Hungarian Algorithm for the Assignment Problem with Changing Costs

TCOM 501: Networking Theory & Fundamentals. Lecture 11 April 16, 2003 Prof. Yannis A. Korilis

Topics in Combinatorial Optimization February 5, Lecture 2

Bipartite Matching & the Hungarian Method

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

11.4 Bipartite Multigraphs

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.

Paths, Trees, and Flowers by Jack Edmonds

γ(ɛ) (a, b) (a, d) (d, a) (a, b) (c, d) (d, d) (e, e) (e, a) (e, e) (a) Draw a picture of G.

Discrete mathematics , Fall Instructor: prof. János Pach

CS 217 Algorithms and Complexity Homework Assignment 2

Approximation Algorithms

Lecture 15: Matching Problems. (Reading: AM&O Chapter 12)

Ma/CS 6b Class 4: Matchings in General Graphs

CS261: A Second Course in Algorithms Lecture #16: The Traveling Salesman Problem

The Structure of Bull-Free Perfect Graphs

Ma/CS 6b Class 5: Graph Connectivity

by conservation of flow, hence the cancelation. Similarly, we have

Math and Marriage - Don t Call a Lawyer Yet!

Math236 Discrete Maths with Applications

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

Data Organization: Creating Order Out Of Chaos

1 Linear programming relaxation

Week 8: The fundamentals of graph theory; Planar Graphs 25 and 27 October, 2017

Kyle Gettig. Mentor Benjamin Iriarte Fourth Annual MIT PRIMES Conference May 17, 2014

Minimum Spanning Trees

Paths, Flowers and Vertex Cover

VIZING S THEOREM AND EDGE-CHROMATIC GRAPH THEORY. Contents

Breadth-First Search L 1 L Goodrich, Tamassia, Goldwasser Breadth-First Search 1

Graph Algorithms Matching

Outline and Reading. Minimum Spanning Tree. Minimum Spanning Tree. Cycle Property. Minimum Spanning Trees ( 12.7)

Kuratowski Notes , Fall 2005, Prof. Peter Shor Revised Fall 2007

Minimum Spanning Trees and Shortest Paths

Extremal Graph Theory: Turán s Theorem

Approximation Algorithms

Matchings in Graphs. Definition 1 Let G = (V, E) be a graph. M E is called as a matching of G if v V we have {e M : v is incident on e E} 1.

2. CONNECTIVITY Connectivity

These notes present some properties of chordal graphs, a set of undirected graphs that are important for undirected graphical models.

CHAPTER-2 A GRAPH BASED APPROACH TO FIND CANDIDATE KEYS IN A RELATIONAL DATABASE SCHEME **

5.1 Min-Max Theorem for General Matching

On vertex types of graphs

Polynomial-Time Approximation Algorithms

1 Algorithm and Proof for Minimum Vertex Coloring

MATH 363 Final Wednesday, April 28. Final exam. You may use lemmas and theorems that were proven in class and on assignments unless stated otherwise.

CS261: Problem Set #2

GRAPH THEORY and APPLICATIONS. Matchings

HW Graph Theory SOLUTIONS (hbovik) - Q

Graph Theory. Connectivity, Coloring, Matching. Arjun Suresh 1. 1 GATE Overflow

Math 102A Hw 3 P a (2 points)

Depth-First Search A B D E C

USA Mathematical Talent Search Round 2 Solutions Year 23 Academic Year

Transcription:

Matchings 7.2 99 lgorithms efinition: n algorithm is a set of rules followed to solve a problem. In general, an algorithm has the steps: 1 Organize the input. 2 Repeatedly apply some steps until a termination condition holds 3 nalyze data upon termination

Matchings 7.2 99 lgorithms efinition: n algorithm is a set of rules followed to solve a problem. In general, an algorithm has the steps: 1 Organize the input. Havel Hakimi: 2 Repeatedly apply some steps until a termination condition holds 3 nalyze data upon termination

Matchings 7.2 99 lgorithms efinition: n algorithm is a set of rules followed to solve a problem. In general, an algorithm has the steps: 1 Organize the input. Havel Hakimi: 2 Repeatedly apply some steps until a termination condition holds 3 nalyze data upon termination omputers can be used to run the algorithms once we verify they work.

Matchings 7.2 99 lgorithms efinition: n algorithm is a set of rules followed to solve a problem. In general, an algorithm has the steps: 1 Organize the input. Havel Hakimi: 2 Repeatedly apply some steps until a termination condition holds 3 nalyze data upon termination omputers can be used to run the algorithms once we verify they work. To verify the correctness of an algorithm: 1 Verify that the algorithm terminates. (often invoking finiteness) 2 Verify that the result satisfies the desired conditions.

UM vs. L 100 side: Maximum vs. Maximal There is an important distinction between maximum and maximal. Maximum refers to an element of absolute largest size. (of LL elts with property, this is largest.) Maximal refers to an element of relative largest size. (for THIS elt with property, no superset has property.)

UM vs. L 100 side: Maximum vs. Maximal There is an important distinction between maximum and maximal. Maximum refers to an element of absolute largest size. (of LL elts with property, this is largest.) Maximal refers to an element of relative largest size. (for THIS elt with property, no superset has property.) xample. maximum vs. maximal path in a graph:

UM vs. L 100 side: Maximum vs. Maximal There is an important distinction between maximum and maximal. Maximum refers to an element of absolute largest size. (of LL elts with property, this is largest.) Maximal refers to an element of relative largest size. (for THIS elt with property, no superset has property.) xample. maximum vs. maximal path in a graph: xample. maximum vs. maximal matching: (next page)

Matchings 7.2 101 Matchings in Graphs efinition: matching M in a graph G is a subset of edges of G that share no vertices.

Matchings 7.2 101 Matchings in Graphs efinition: matching M in a graph G is a subset of edges of G that share no vertices. efinition: maximal matching M is a matching such that the inclusion into M of any edge of G \M is no longer a matching. efinition: maximum matching is a matching M that has the most edges possible for the graph G.

Matchings 7.2 101 Matchings in Graphs efinition: matching M in a graph G is a subset of edges of G that share no vertices. efinition: maximal matching M is a matching such that the inclusion into M of any edge of G \M is no longer a matching. efinition: maximum matching is a matching M that has the most edges possible for the graph G. Thought xercise: What is the result of overlapping two matchings?

Matchings 7.2 101 Matchings in Graphs efinition: matching M in a graph G is a subset of edges of G that share no vertices. efinition: maximal matching M is a matching such that the inclusion into M of any edge of G \M is no longer a matching. efinition: maximum matching is a matching M that has the most edges possible for the graph G. Thought xercise: What is the result of overlapping two matchings? Recall. perfect matching is a matching involving every vertex of G. We will discuss matchings in a bipartite graph

Matchings 7.2 102 pplication: Scheduling Suppose you are working in a group trying to complete all the problems on the homework. epending on everyone s preferences, you would like to assign each member one problem to do. Person likes problems 1, 2, 3, and 5. Person likes problems 1, 2, and 4. Person likes problems 3, 4, and 5. Person likes problems 2 and 3. Person likes problems 3 and 4.

Matchings 7.2 102 pplication: Scheduling Suppose you are working in a group trying to complete all the problems on the homework. epending on everyone s preferences, you would like to assign each member one problem to do. Person likes problems 1, 2, 3, and 5. Person likes problems 1, 2, and 4. Person likes problems 3, 4, and 5. Person likes problems 2 and 3. Person likes problems 3 and 4. reate a graph that models the situation.

Matchings 7.2 102 pplication: Scheduling Suppose you are working in a group trying to complete all the problems on the homework. epending on everyone s preferences, you would like to assign each member one problem to do. Person likes problems 1, 2, 3, and 5. Person likes problems 1, 2, and 4. Person likes problems 3, 4, and 5. Person likes problems 2 and 3. Person likes problems 3 and 4. reate a graph that models the situation. Question: What is a maximum matching for this graph? We will use an algorithm to answer this question.

Matchings 7.2 103 Motivating The Hungarian lgorithm Let us work through the basic idea behind the algorithm. We start with an initial matching; we might as well make it maximal. Why is the pictured matching maximal?

Matchings 7.2 103 Motivating The Hungarian lgorithm Let us work through the basic idea behind the algorithm. We start with an initial matching; we might as well make it maximal. Why is the pictured matching maximal? efinition: Given a matching M in a graph G, an M-alternating path is a path in G that starts at a vertex not in M, and whose edges alternate between being in M and not in M.

Matchings 7.2 103 Motivating The Hungarian lgorithm Let us work through the basic idea behind the algorithm. We start with an initial matching; we might as well make it maximal. Why is the pictured matching maximal? efinition: Given a matching M in a graph G, an M-alternating path is a path in G that starts at a vertex not in M, and whose edges alternate between being in M and not in M. xample 2 4 is an M-alternating path.

Matchings 7.2 103 Motivating The Hungarian lgorithm Let us work through the basic idea behind the algorithm. We start with an initial matching; we might as well make it maximal. Why is the pictured matching maximal? efinition: Given a matching M in a graph G, an M-alternating path is a path in G that starts at a vertex not in M, and whose edges alternate between being in M and not in M. xample 2 4 is an M-alternating path. efinition: n M-augmenting path is an M-alternating path that begins N ends at unmatched vertices. It is augmenting because we can improve M by toggling the edges between those in M and those not in M.

Matchings 7.2 104 Motivating The Hungarian lgorithm

Matchings 7.2 104 Motivating The Hungarian lgorithm Given M, P = 2 1 is an M-augmenting path. Toggling the edges in P gives a new matching M.

Matchings 7.2 104 Motivating The Hungarian lgorithm Given M, P = 2 1 is an M-augmenting path. Toggling the edges in P gives a new matching M.

Matchings 7.2 104 Motivating The Hungarian lgorithm Given M, P = 2 1 is an M-augmenting path. Toggling the edges in P gives a new matching M. Given M, P = 4 3 5 is an M -augmenting path. Toggling the edges in P gives a new matching M.

Matchings 7.2 104 Motivating The Hungarian lgorithm Given M, P = 2 1 is an M-augmenting path. Toggling the edges in P gives a new matching M. Given M, P = 4 3 5 is an M -augmenting path. Toggling the edges in P gives a new matching M. The matching M is maximal. (Why?)

Matchings 7.2 105 The Hungarian lgorithm The Hungarian lgorithm (Kuhn, Kőnig, geváry) [Finds a maximum matching in a bipartite graph (w/red and blue vertices)]

Matchings 7.2 105 The Hungarian lgorithm The Hungarian lgorithm (Kuhn, Kőnig, geváry) [Finds a maximum matching in a bipartite graph (w/red and blue vertices)] 1 Start with a bipartite graph G and any matching M. Label all red vertices eligible (for augmentation).

Matchings 7.2 105 The Hungarian lgorithm The Hungarian lgorithm (Kuhn, Kőnig, geváry) [Finds a maximum matching in a bipartite graph (w/red and blue vertices)] 1 Start with a bipartite graph G and any matching M. Label all red vertices eligible (for augmentation). 2 If all red, eligible vertices are matched, stop. Otherwise, there exists a red, unmatched, eligible vertex to use in the next step.

Matchings 7.2 105 The Hungarian lgorithm The Hungarian lgorithm (Kuhn, Kőnig, geváry) [Finds a maximum matching in a bipartite graph (w/red and blue vertices)] 1 Start with a bipartite graph G and any matching M. Label all red vertices eligible (for augmentation). 2 If all red, eligible vertices are matched, stop. Otherwise, there exists a red, unmatched, eligible vertex to use in the next step. 3 Let v be an unmatched, eligible, red vertex. Start growing all possible M-alternating paths from v. That is, follow every edge not in M to a blue vertex. From a matched blue vertex, follow the edge of M back to a red vertex, and repeat as far as possible.

Matchings 7.2 105 The Hungarian lgorithm The Hungarian lgorithm (Kuhn, Kőnig, geváry) [Finds a maximum matching in a bipartite graph (w/red and blue vertices)] 1 Start with a bipartite graph G and any matching M. Label all red vertices eligible (for augmentation). 2 If all red, eligible vertices are matched, stop. Otherwise, there exists a red, unmatched, eligible vertex to use in the next step. 3 Let v be an unmatched, eligible, red vertex. Start growing all possible M-alternating paths from v. That is, follow every edge not in M to a blue vertex. From a matched blue vertex, follow the edge of M back to a red vertex, and repeat as far as possible. { If there is an M-augmenting path, toggle edges to augment M. If there is no M-augmenting path, mark a ineligible.

Matchings 7.2 105 The Hungarian lgorithm The Hungarian lgorithm (Kuhn, Kőnig, geváry) [Finds a maximum matching in a bipartite graph (w/red and blue vertices)] 1 Start with a bipartite graph G and any matching M. Label all red vertices eligible (for augmentation). 2 If all red, eligible vertices are matched, stop. Otherwise, there exists a red, unmatched, eligible vertex to use in the next step. 3 Let v be an unmatched, eligible, red vertex. Start growing all possible M-alternating paths from v. That is, follow every edge not in M to a blue vertex. From a matched blue vertex, follow the edge of M back to a red vertex, and repeat as far as possible. { If there is an M-augmenting path, toggle edges to augment M. If there is no M-augmenting path, mark a ineligible. Return to Step 2.

Matchings 7.2 106 pplying the Hungarian lgorithm Here is something that might happen during an application of the Hungarian algorithm: xample. There is no M-augmenting path starting at in the graph to the right. F G H We would mark ineligible and move on to the next eligible, unmatched red vertex in the graph (). I J

Matchings 7.2 107 Proof of orrectness laim. The Hungarian lgorithm gives a maximum matching. Proof. We must show that the algorithm always stops, and that when it stops, the output is indeed a maximum matching. The algorithm terminates.

Matchings 7.2 107 Proof of orrectness laim. The Hungarian lgorithm gives a maximum matching. Proof. We must show that the algorithm always stops, and that when it stops, the output is indeed a maximum matching. The algorithm terminates. ach time Step 3 is run, one red vertex either becomes matched or becomes ineligible. lso, no red vertex that starts matched becomes unmatched. Since there are a finite number of red vertices, the algorithm must terminate.

Matchings 7.2 107 Proof of orrectness laim. The Hungarian lgorithm gives a maximum matching. Proof. We must show that the algorithm always stops, and that when it stops, the output is indeed a maximum matching. The algorithm terminates. ach time Step 3 is run, one red vertex either becomes matched or becomes ineligible. lso, no red vertex that starts matched becomes unmatched. Since there are a finite number of red vertices, the algorithm must terminate. The output is a maximum matching.

Matchings 7.2 107 Proof of orrectness laim. The Hungarian lgorithm gives a maximum matching. Proof. We must show that the algorithm always stops, and that when it stops, the output is indeed a maximum matching. The algorithm terminates. ach time Step 3 is run, one red vertex either becomes matched or becomes ineligible. lso, no red vertex that starts matched becomes unmatched. Since there are a finite number of red vertices, the algorithm must terminate. The output is a maximum matching. The output M is a matching inducing no M-augmenting paths in the graph. Suppose that there were another matching M that used more edges than M.

Matchings 7.2 107 Proof of orrectness laim. The Hungarian lgorithm gives a maximum matching. Proof. We must show that the algorithm always stops, and that when it stops, the output is indeed a maximum matching. The algorithm terminates. ach time Step 3 is run, one red vertex either becomes matched or becomes ineligible. lso, no red vertex that starts matched becomes unmatched. Since there are a finite number of red vertices, the algorithm must terminate. The output is a maximum matching. The output M is a matching inducing no M-augmenting paths in the graph. Suppose that there were another matching M that used more edges than M. When we overlap M and M, the result is a union of cycles and paths. t least one path must have more edges from M than M.

Matchings 7.2 107 Proof of orrectness laim. The Hungarian lgorithm gives a maximum matching. Proof. We must show that the algorithm always stops, and that when it stops, the output is indeed a maximum matching. The algorithm terminates. ach time Step 3 is run, one red vertex either becomes matched or becomes ineligible. lso, no red vertex that starts matched becomes unmatched. Since there are a finite number of red vertices, the algorithm must terminate. The output is a maximum matching. The output M is a matching inducing no M-augmenting paths in the graph. Suppose that there were another matching M that used more edges than M. When we overlap M and M, the result is a union of cycles and paths. t least one path must have more edges from M than M. This path is an M-augmenting path, contradicting the definition of M.