matchings example freya buys some chocolates to share with her friends. there are six chocolates –...
TRANSCRIPT
MatchingsExampleExample
Freya buys some chocolates to share with her friends. There are six chocolates – raspberry rage (R) , truffle tickle (T), nut nibble (N), strawberry supreme (S), walnut whirl (W) and marshmallow melt (M). Of her friends, Ann likes raspberry rage and marshmallow melt; Baz likes strawberry supreme; Carl likes nut nibble and marshmallow melt; Dee likes truffle tickle, nut nibble and walnut whirl; and Ellie likes strawberry supreme and marshmallow melt. Freya herself likes raspberry rage, truffle tickle and strawberry supreme.Can they each have a chocolate they like?
MatchingsBipartite graphs
We can represent this situation using a bipartite graph. This is a graph with two distinct sets; the friends and the chocolates. The edges only go from a vertex in one set to a vertex in the other; in this case where the person likes that particular chocolate.
We can represent this situation using a bipartite graph. This is a graph with two distinct sets; the friends and the chocolates. The edges only go from a vertex in one set to a vertex in the other; in this case where the person likes that particular chocolate.
Ana
Baz
Carl
Dee
Ellie
Freya
R. raspberry rage
T. truffle tickle
N. nut nibble
S. strawberry supreme
W. walnut whirl
M. marshmallow melt
Anna likes raspberry rage and marshmallow meltAnna likes raspberry rage and marshmallow meltBaz likes strawberry supremeBaz likes strawberry supremeCarl likes nut nibble and marshmallow meltCarl likes nut nibble and marshmallow meltDee likes truffle tickle, nut nibble and walnut whirlDee likes truffle tickle, nut nibble and walnut whirlEllie likes strawberry supreme and marshmallow meltEllie likes strawberry supreme and marshmallow meltFreya likes raspberry rage, truffle tickle and strawberry supremeFreya likes raspberry rage, truffle tickle and strawberry supreme
Initial Matching
If we now pair people with particular chocolates they like in a one-to-one way (no two people to the same chocolate, no two chocolates to one person) then we have a matching.
If we now pair people with particular chocolates they like in a one-to-one way (no two people to the same chocolate, no two chocolates to one person) then we have a matching.
If a matching includes the same number of edges as vertices in each set (6 in this case) then it is called a complete matching.
The diagram shows the matching
A-R, B-S, C-N, D-T, E-M
THIS MATCHING IS NOT COMPLETE
If a matching includes the same number of edges as vertices in each set (6 in this case) then it is called a complete matching.
The diagram shows the matching
A-R, B-S, C-N, D-T, E-M
THIS MATCHING IS NOT COMPLETE
A
B
C
D
E
F
R.
T.
N.
S.
W.
M.
MatchingsAlternating paths
If we have a matching and want to improve it we can do so by finding an alternating path. This is a path which
(a) Starts on an unmatched vertex on the right hand side [W]
(b) Consists of edges alternately not in and in the matching
(c) Finishes on an unmatched vertex in the second set
If we have a matching and want to improve it we can do so by finding an alternating path. This is a path which
(a) Starts on an unmatched vertex on the right hand side [W]
(b) Consists of edges alternately not in and in the matching
(c) Finishes on an unmatched vertex in the second set
Start with W
join to W to D
Now remove D-T
T now has no match so include T-F
F was previously unmatched, so we have now have breakthrough.
The alternating path is W-D-T-F
Every vertex is now matched so we have a complete matching
Start with W
join to W to D
Now remove D-T
T now has no match so include T-F
F was previously unmatched, so we have now have breakthrough.
The alternating path is W-D-T-F
Every vertex is now matched so we have a complete matching
A
B
C
D
E
F
R.
T.
N.
S.
W.
M.
MatchingsAlternating paths
The solution consists of
1. Edges in the alternating path but not in the initial matching;
D-W and F-T
2. Edges in the initial matching but not in the alternating path;
A-R, B-S, C-N and E-M
The solution consists of
1. Edges in the alternating path but not in the initial matching;
D-W and F-T
2. Edges in the initial matching but not in the alternating path;
A-R, B-S, C-N and E-M
Interpretation:
Ann has raspberry rage
Baz has strawberry supreme
Carl had nut nibble
Dee has walnut whirl
Ellie has marshmallow melt
Freya has truffle tickle.
Interpretation:
Ann has raspberry rage
Baz has strawberry supreme
Carl had nut nibble
Dee has walnut whirl
Ellie has marshmallow melt
Freya has truffle tickle.
A
B
C
D
E
F
R.
T.
N.
S.
W.
M.
Student Jobs Matching
Past Exam Qu.sJune 2005
Past Exam Qu.sJan 2004