9
SPORTS MATCHINGS

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

Embed Size (px)

Citation preview

Page 1: 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

SPORTS MATCHINGS

Page 2: 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

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?

Page 3: 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

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

B

C

D

H

R

S

T

Page 4: 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

YOUR BIPARTITE GRAPHS

Your bipartite graphs for your complete matchings (found earlier) should look like the

following:

A

B

C

D

H

R

S

T

A

B

C

D

H

R

S

T

A

B

C

D

H

R

S

T

Page 5: 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

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.)

Page 6: 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

MAXIMUM MATCHING ALGORITHMAn alternating path 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 maximum matching algorithm is as follows:

1. Start with any initial matching.2. Find an alternating path.3. If an alternating path can be found, use it to create an improved

matching by changing the arcs as appropriate. 4. List the new matching, consisting of any unchanged elements in

the initial matching, together with any changed arcs from the alternating path.

5. 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?

Page 7: 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

MAXIMUM MATCHING ALGORITHMWe will now use this algorithm to find an improved matching

from out initial matching drawn earlier.

A

B

C

D

H

R

S

T

Initial Matching:Ann = RugbyBen = HockeyCaroline = SwimmingDarren = Tennis (NOT HIS PREFERENCE)

Step 1:

A

B

C

D

H

R

S

T

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.

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.

Page 8: 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

MAXIMUM MATCHING ALGORITHM

A

B

C

D

H

R

S

T

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.

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.

Our complete matching is:

Ann = RugbyBen = HockeyCaroline = TennisDarren = Swimming

Page 9: 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

EVALUATION

1) What is the benefit of being able to use the algorithms talked about to create matchings?

2) Did you find anything difficult about today’s lesson? Explain.

3) When do you think you would use the idea of matchings again in the future?

4) Can you think of any real life examples of where these matching algorithms are/could be used?