Sunuyu indir
Sunum yükleniyor. Lütfen bekleyiniz
YayınlayanAlparslan Sayin Değiştirilmiş 9 yıl önce
1
Atama ve eşleme (eşleştirme) problemleri (Matching and Assignment problems)
5
Hall Teoremi: Sözel olarak:
Eğer her bir erkek grubu için onların hoşlandıkları kızlar grubu daha genişse, her bir erkek isteğine göre kız bulabilir
7
a x b e c z y w d
10
Sözel olarak: Eğer her bir erkek yeterince istekli ise (k´dan fazla kızla ilgileniyorsa) ve
hiç bir kız özel ilgi görmüyorsa (k´dan fazla ilgi görmüyorsa), her bir erkek isteğine göre kız bulabilir.
11
Ör. :. 50 öğrenciden oluşan bir sınıfta 25 erkek ve 25 kız vardır
Ör.: 50 öğrenciden oluşan bir sınıfta 25 erkek ve 25 kız vardır. Her erkek =5 kızdan hoşlanıyor. Her kız için ondan hoşlanan =5 erkek vardır. Bir okul partisine her erkek hoşlandığı bir kız ile katılabilir mi?
13
Ör. :. 45 öğrenciden oluşan bir sınıfta 20 erkek ve 25 kız vardır
Ör.: 45 öğrenciden oluşan bir sınıfta 20 erkek ve 25 kız vardır. Her erkek =5 kızdan hoşlanıyor. Her kız için ondan hoşlanan =4 erkek vardır. Bir okul partisine her erkek hoşlandığı bir kız ile katılabilir mi?
21
Unweighted Bipartite Matching
22
Definitions Matching Free Vertex
23
Definitions Maximum Matching: matching with the largest number of edges
24
Definition Note that maximum matching is not unique.
25
Intuition Let the top set of vertices be men
Let the bottom set of vertices be women Suppose each edge represents a pair of man and woman who like each other Maximum matching tries to maximize the number of couples!
26
Applications Matching has many applications.
This lecture lets you know how to find maximum matching.
27
Alternating Path Alternating between matching and non-matching edges.
f g h i j d-h-e: alternating path a-f-b-h-d-i: alternating path starts and ends with free vertices f-b-h-e: not alternating path e-j: alternating path starts and ends with free vertices
28
Idea “Flip” augmenting path to get better matching
Note: After flipping, the number of matched edges will increase by 1!
29
Idea of Algorithm Start with an arbitrary matching
While we still can find an augmenting path Find the augmenting path P Flip the edges in P
30
Breadth-First Search Algorithm for Augmented Path
Use Breadth-First Search: LEVEL(0) = some unmatched vertex r for odd L > 0, LEVEL(L) = {u|{v,u} E – M when v LEVEL(L -1) and when u in no lower level} For even L > 0, LEVEL(L) = {u|{v,u} M and u in no lower level} Assume G is bipartite graph with matching M.
31
Labelling Algorithm Start with arbitrary matching
32
Labelling Algorithm Pick a free vertex in the bottom
33
Labelling Algorithm Run BFS
34
Labelling Algorithm Alternate unmatched/matched edges
35
Labelling Algorithm Until a augmenting path is found
36
Augmenting Tree
37
Flip!
38
Repeat Pick another free vertex in the bottom
39
Repeat Run BFS
40
Repeat Flip
41
Answer Since we cannot find any augmenting path, stop!
42
Overall algorithm Start with an arbitrary matching (e.g., empty matching) Repeat forever For all free vertices in the bottom, do bfs to find augmenting paths If found, then flip the edges If fail to find, stop and report the maximum matching.
43
Time analysis We can find at most |V| augmenting paths (why?)
To find an augmenting path, we use bfs! Time required = O( |V| + |E| ) Total time: O(|V|2 + |V| |E|)
44
Improvement We can try to find augmenting paths in parallel for all free nodes in every iteration. Using such approach, the time complexity is improved to O(|V|0.5 |E|)
45
Stable Marriage Problem
46
Stable Marriage Problem
Given N men and N women, each person list in order of preference all the people of the opposite sex who would like to marry. Problem: Engage all the women to all the men in such a way as to respect all their preferences as much as possible.
47
Stable? A set of marriages is unstable if
two people who are not married both prefer each other than their spouses E.g. Suppose we have A1 B3 C2 D4 E5. This is unstable since A prefer 2 more than 1 2 prefer A more than C A B C D E 2 5 1 3 4
48
Naïve solution Starting from a feasible solution.
Check if it is stable. If yes, done! If not, remove an unstable couple. Is this work?
49
Naïve solution (2) Does not work! E.g. A1 B3 C2 D4 E5 A2 B3 C1 D4 E5
50
Solution Let X be the first man.
X proposes to the best woman in the remaining on his list. (Initially, the first woman on his list!) If α is not engaged Pair up (X, α). Then, set X=next man and goto 1. If α prefers X more than her fiancee Y, Pair up (X, α). Then, set X=Y and goto 1. Goto 1
51
Example A B C D E 2 1 2 1 5 5 2 3 3 3 1 3 5 2 A B C D E 2 5 1 3 4 4
52
Time analysis If there are N men and N women, O(N2) time
Benzer bir sunumlar
© 2024 SlidePlayer.biz.tr Inc.
All rights reserved.