JessicaManager JasonProduce section RobertShelf Stacking CharlotteTrolleys LauriDeli EdCheckout Matching the elements of 2 different sets occurs when for.

Slides:



Advertisements
Similar presentations
Decision Maths Dijkstra’s Algorithm.
Advertisements

LIAL HORNSBY SCHNEIDER
Chapter 3: Planning and Scheduling Lesson Plan
What is an isometric drawing?
R. Johnsonbaugh Discrete Mathematics 5 th edition, 2001 Chapter 8 Network models.
Tutorial 6 of CSCI2110 Bipartite Matching Tutor: Zhou Hong ( 周宏 )
 Graph Graph  Types of Graphs Types of Graphs  Data Structures to Store Graphs Data Structures to Store Graphs  Graph Definitions Graph Definitions.
Koenigsberg bridge problem It is the Pregel River divided Koenigsberg into four distinct sections. Seven bridges connected the four portions of Koenigsberg.
Matchings Example Freya buys some chocolates to share with her friends. There are six chocolates – raspberry rage (R), truffle tickle (T), nut nibble (N),
The Hungarian algorithm for non-square arrays
The Instant Insanity Game
Section 2.1 Euler Cycles Vocabulary CYCLE – a sequence of consecutively linked edges (x 1,x2),(x2,x3),…,(x n-1,x n ) whose starting vertex is the ending.
04/12/2005Tucker, Sec Applied Combinatorics, 4 th Ed. Alan Tucker Section 4.4 Algorithmic Matching Prepared by Joshua Schoenly and Kathleen McNamara.
Network Optimization Problems: Models and Algorithms This handout: Minimum Spanning Tree Problem.
Spanning Trees.
Matchings Lecture 3: Jan 18. Bipartite matchings revisited Greedy method doesn’t work (add an edge with both endpoints free)
Tucker, Applied Combinatorics, Section 1.4, prepared by Patti Bodkin
3/24/03Tucker, Section 4.31 Tucker, Applied Combinatorics, Sec. 4.3, prepared by Jo E-M Bipartite GraphMatching Some Definitions X-Matching Maximal Matching.
WB13 Define the terms bipartite graph,
D1: Matchings.
Spanning Trees. Spanning trees Suppose you have a connected undirected graph –Connected: every node is reachable from every other node –Undirected: edges.
INSTANT INSANITY PUZZLE By Patrick K. Asaba. INSTANT INSANITY PUZZLE The Instant Insanity puzzle is played with four cubes. Each face of the cube is colored.
Linear Inequalities in Two Variables
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley. All rights reserved.
 Jim has six children.  Chris fights with Bob,Faye, and Eve all the time; Eve fights (besides with Chris) with Al and Di all the time; and Al and Bob.
Lecture 12-2: Introduction to Computer Algorithms beyond Search & Sort.
Chapter 01 – Section 08 A Preview of Graphs and Functions.
10.4 How to Find a Perfect Matching We have a condition for the existence of a perfect matching in a graph that is necessary and sufficient. Does this.
5.1  Routing Problems: planning and design of delivery routes.  Euler Circuit Problems: Type of routing problem also known as transversability problem.
Copyright © Cengage Learning. All rights reserved. CHAPTER 10 GRAPHS AND TREES.
Graphing Linear Inequalities in Two Variables Chapter 4 – Section 1.
1 Sections 5.1 & 5.2 Inequalities in Two Variables After today’s lesson, you will be able to graph linear inequalities in two variables. solve systems.
(CSC 102) Lecture 28 Discrete Structures. Graphs.
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.
All Pair Shortest Path IOI/ACM ICPC Training June 2004.
Chapter 2 Section 1. Objective Students will interpret the meaning of presented data and determine if the data represents a function. They will also be.
Bipartite Matching. Unweighted Bipartite Matching.
© 2010 Pearson Prentice Hall. All rights reserved. CHAPTER 15 Graph Theory.
1Barnett/Ziegler/Byleen Finite Mathematics 12e Learning Objectives for Section 5.2  The student will be able to solve systems of linear inequalities graphically.
Graphs A ‘Graph’ is a diagram that shows how things are connected together. It makes no attempt to draw actual paths or routes and scale is generally inconsequential.
Activity diagrams M Taimoor Khan
CIRCUITS, PATHS, AND SCHEDULES Euler and Königsberg.
Introduction to Graph Theory Lecture 13: Graph Coloring: Edge Coloring.
Introduction to Graph Theory
Prims Algorithm for finding a minimum spanning tree
Tree Diagrams A tree is a connected graph in which every edge is a bridge. There can NEVER be a circuit in a tree diagram!
Iterative Improvement for Domain-Specific Problems Lecturer: Jing Liu Homepage:
MATCHINGS A college dramatic society has six helpers: Andrew, Donna, Henry, Karl, Nicola and Yana. They are to be matched to six tasks: Props, Lighting,
DECISION 1. How do you do a Bubble Sort? Bubble Sort:  You compare adjacent items in a list;  If they are in order, leave them.  If they are not in.
Teacher Notes: There is a famous problem in Discrete Mathematics called ‘The Bridges of Konigsberg’ in which it is said to be impossible to cross each.
The Hungarian Algorithm – Maximisation problems The Hungarian algorithm for maximisation problems To solve a maximisation problem using the Hungarian algorithm,
Leda Demos By: Kelley Louie Credits: definitions from Algorithms Lectures and Discrete Mathematics with Algorithms by Albertson and Hutchinson graphics.
MAT 2720 Discrete Mathematics Section 8.1 Introduction
IOI/ACM ICPC Training 4 June 2005.
The Hungarian algorithm for non-square arrays
Lecture 16 Bipartite Matching
Redraw this PCB in such a way that no wires cross.
Review: Mini-Quiz Matching
The Taxi Scheduling Problem
Spanning Trees Longin Jan Latecki Temple University based on slides by
Instructor: Shengyu Zhang
Decision Maths Dijkstra’s Algorithm.
Shortest Path.
Matchings If they ask you to show the matching on a diagram (say there are four matchings) don’t just highlight them with a thicker line on the bipartite.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
The Hungarian algorithm for non-square arrays
Lecture 4: Matching Algorithms
Section 13.4 Trees.
Closures of Relations Epp, section 10.1,10.2 CS 202.
Presentation transcript:

JessicaManager JasonProduce section RobertShelf Stacking CharlotteTrolleys LauriDeli EdCheckout Matching the elements of 2 different sets occurs when for example one tries to match up jobs with the people available. Certain people may be only able to do certain jobs. Matching Algorithm

We wish to find the matching which minimises the cost of the deliveries. Four supermarkets W, X, Y and Z are supplied by four warehouses A, B, C and D. The cost of supplying the supermarkets ( fuel, labour etc) is shown in the table below. Warehouse Supermarket

Consider how best to allocate the swimmers for a medley relay team given their times below We need to minimise the total time.

Matchings Example 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?

Matchings Bipartite 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. 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 melt Baz likes strawberry supreme Carl likes nut nibble and marshmallow melt Dee likes truffle tickle, nut nibble and walnut whirl Ellie likes strawberry supreme and marshmallow melt Freya 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 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.

Matchings Alternating 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.

Matchings Alternating 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.

The next problem is matching people with jobs. We are not concerned with minimising costs or times or maximising profits. All we need is to match people with jobs so that as many jobs as possible are completed

JessicaManager JasonProduce section RobertShelf Stacking CharlotteTrolleys LauriDeli EdCheckout Matching Algorithm Jobs that past students were capable of at a supermarket

JessicaManager JasonProduce section RobertShelf Stacking CharlotteTrolleys Lauri Deli EdCheckout Method of Solving:Draw a bipartite graph and start with any matching– shown in black lines. All the people/jobs won’t be included as it will not be a maximal matching. Label all the left vertices (people) which don’t belong to the matching M with a * * Lauri cannot do shelf stacking so they are not included in the matching. The blue lines indicate the jobs that can be done by each person

JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Choose a newly * labelled left vertex (Lauri) and label a right vertex joined by an arc not in the matching M to the * (Blue arcs). * Lauri to Checkout 1 Step

JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Choose a newly labelled right vertex and label a left vertex joined by an arc in the matching M. Black arcs * Checkout back to Ed 2 Step

JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Now repeat steps 2 and 3 until no more labelling is possible i.e Blue arcs * Ed forward to Shelves 3 Step

JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout As Shelves is not in the original matching Breakthrough has been achieved. * 4 Step The alternating path Shelves –EdCheckout–Lauri + the original matchings Charlotte–Manager Produce–Jessica Deli–Jason Trolleys–Robert Use the solid red + the black arcs

JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Choose a newly * labelled left vertex (Lauri) and label all the right vertices joined by an arc not in the matching M to the * (Blue arcs). * i.e Lauri to Produce 1 Step Alternative Matching 2

JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Choose a newly labelled right vertex and label a left vertex joined by an arc in the matching M. Black arcs * i.e Produce back to Jessica 2 Step

JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Now repeat steps 2 and 3 until no more labelling is possible i.e Blue arcs * Jessica forward to Checkout 3 Step

JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Black arcs * Checkout back to Ed 3 Step

JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Blue arcs * Ed forward to Shelves 3 Step

As Shelves is not in the original matching Breakthrough has been achieved. 4 Step The alternating path Shelves–Ed Checkout–Jessica Produce–Laurie + the original matchings Charlotte–Manager Deli–Jason Trolleys–Robert JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout * Use the solid red + the black arcs

JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Choose a newly * labelled left vertex (Lauri) and label a right vertx joined by an arc not in the matching M to the * (Blue arcs). * i.e Lauri to Produce 1 Step Alternative Matching 3

JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Choose a newly labelled right vertex and label a left vertex joined by an arc in the matching M. Black arcs * i.e Produce back to Jessica 2 Step

JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Now repeat steps 2 and 3 until no more labelling is possible i.e Blue arcs * Jessica forward to Checkout 3 Step

JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout * Checkout back to Ed 4 Step Black arcs

JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout * Ed forward to Trolleys 4 Step Blue arcs

JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout * Trolleys back to Robert 4 Step Black arcs

JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout * Robert forward to Shelves 4 Step Blue arcs

JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout * As Shelves is not in the original matching Breakthrough has been achieved. 4 Step The alternating path Shelves–Robert Trolleys–Ed Checkout–Jessica Produce–Laurie + the original matchings Charlotte–Manager Deli–Jason Use the solid red + the black arcs

Past Exam Qu.s June 2005

Past Exam Qu.s Jan 2004