90 likes | 225 Views
Sports Matchings. Your Task. Your are the sports captain of your school . There are four different sports teams which are looking for one more person to fill each team. You have been given the following preferences of four different students who you wish to allocate to one team each.
E N D
Your Task • Your are the sports captain of your school . There are four different sports teams • which are looking for one more person to fill each team. You have been given the • following preferences of four different students who you wish to allocate to one team • each. • Ann likes hockey, rugby and swimming. • Ben likes hockey and swimming. • Caroline likes hockey, swimming and tennis. • Darren likes rugby and swimming. • Using this information, find a suitable matching so that each student • is accepted onto a team of their choice. • Can you find more than one possible matching?
Bipartite graphs • There is a special way to present this information. This is called a bipartite graph. It • consists of two sets of vertices, X and Y, and the edges only connect vertices in X to • vertices in Y (i.e. no two vertices in one set are ever joined). • Here is the bipartite graph for the data given to us about the students’ preferences. • Let A = Ann, B = Ben, C = Caroline, D = Darren, H = Hockey, R = Rugby, • S = Swimming, and T = Tennis. A H R B C S T D
Your bipartite graphs • Your bipartite graphs for your complete matchings (found earlier) should look like the • following: A A H H A H B B R R B R C C C S S S D D T T D T
Initial matching • Task 2: • Your Head of the PE Department has just informed you that he has already allocated the students to one team each, however Darren was not allocated to a team of his preference. • Caroline was positioned in the swimming team. Over the weekend however, she has found out that she has an ear infection, therefore would like to swap teams. You would like to use this opportunity to ensure that every student from the original list is allocated a team of their preference. • Create an initial matching, using this information, and find an improved matching , from this. • (Note: You want to swap the least amount of students possible, in order to do this.)
Maximum matching algorithm • An alternatingpath starts from one unmatched note on one side of the graph, and • finishes at one unmatched node on the other side of the graph. It uses arcs that are • alternately “in” and “not in” the matching. • The maximummatching algorithm is as follows: • Start with any initial matching. • Find an alternating path. • If an alternating path can be found, use it to create an improved matching by changing the arcs as appropriate. • List the new matching, consisting of any unchanged elements in the initial matching, together with any changed arcs from the alternating path. • If no other alternating paths can be found (and all nodes are reached), the matching is complete. • When might a maximum matching not also be a complete matching?
Maximum matching algorithm • We will now use this algorithm to find an improved matching from out initial matching • drawn earlier. Step 2: We will take the unmatched node T. C is the only node in set X which can match to T. Therefore we match C to T and remove C to S. Step 1: H A R B H A C S R B T D C S Initial Matching: Ann = Rugby Ben = Hockey Caroline = Swimming Darren = Tennis (NOT HIS PREFERENCE) T D We start writing our alternating path here as: T – C = S. By changing the matchings in the alternative path, we hence get T = C – S.
Maximum matching algorithm Step 3: We now look at the unmatched node S. The possible matchings for S are A, C or D. As A is already matched to R and C is already matched to D, the only possibility for S is if D is matched to it. Step 4: All nodes are now matched and there are no more alternating paths, therefore we have found a maximal matching, which is also a complete matching. H A R Our complete matching is: Ann = Rugby Ben = Hockey Caroline = Tennis Darren = Swimming B C S T D Continuing our alternate path, we have S - D to end. Our complete alternate path is hence T – C = S – D. Changing these matchings in the alternate path, we hence get T = C – S = D, as shown above.
Evaluation • What is the benefit of being able to use the algorithms talked about to create matchings? • Did you find anything difficult about today’s lesson? Explain. • When do you think you would use the idea of matchings again in the future? • Can you think of any real life examples of where these matching algorithms are/could be used?