Die Präsentation wird geladen. Bitte warten

Die Präsentation wird geladen. Bitte warten

Matchings (Paarungen) in Graphen

Ähnliche Präsentationen


Präsentation zum Thema: "Matchings (Paarungen) in Graphen"—  Präsentation transkript:

1 Matchings (Paarungen) in Graphen
PS Algorithmen auf Graphen SS `06 Steven Birr

2 Gliederung 1) Definitionen und Beispiele
2) Algorithmus des maximalen Matchings 3) Das Personal-Zuteilungsproblem Ungarischer Algorithmus 4) Zusammenfassung

3 1) Definition: Matching
Geg: G = Graph V=V(G) = Knotenmenge E=E(G) = Kantenmenge Matching M: Untermenge M von E heißt Matching von G, wenn keine 2 Kanten aus M adjazent sind Oder: Keine 2 Kanten aus M haben einen gemeinsamen Endknoten

4 1) Beispiel 1 für ein Matching
M1 = {e1,e2) e1 a c e2 d f e

5 1) Beispiel 2 für ein Matching
M1 = {e1,e3,e4) e1 a c e3 d e4 f e

6 1) Definition: M-gesättigt
v ist Endknoten einer Kante in dem Matching M  v ist M-gesättigt sonst: M-ungesättigt

7 1) Definition: Perfektes Matching
Wenn jeder Knoten eines Matchings M-gesättigt ist  Perfektes Matching

8 1) Definition: Maximales Matching
Matching M heißt maximal, wenn G kein Matching M‘ enthält, das eine größere Anzahl von Kanten als M hat.

9 1) Definition: M-alternierender Weg
Geg.: Matching M in G Kantenmenge E = E(G) M-alternierender Weg in G: Weg, dessen Kanten abwechselnd zu M und E\M gehören

10 1) Bsp. für M-alternierender Weg
v1 v2 v3 e1 e2 a e3 e5 e6 e4 e9 e7 e8 e10 e11 v4 v5 v6 e12 v7 Matching M = {e3, e5, e6} M-alternierender Weg = {v1, v4, v2, v5, v6, v3}

11 1) Definition: M-erweiternder Weg
M-erweiterender Weg: Anfangs- und Endknoten sind M-ungesättigt Matching M = {e4, e6, e7} M-erweiternder Weg = {v5, v6, v1, v2, v7, v8, v3, v4}

12 1) Beispiel aus der Praxis
Immobilienmakler: verschiedene Häuser Verschiedene Kaufinteressenten, die sich evtl. für mehr als 1 Haus interessieren Makler verdient an jedem Geschäftsabschluss eine Provision  Gewinnmaximierung durch Matching

13 1) Beispiel aus der Praxis
G: Graph mit Knotenmenge K für Käufer und H für Häuser Bei Kaufinteresse Kante zwischen Haus- und Käuferknoten Jede Kante bekommt eine Bewertung (Provision)

14 1) Beispiel aus der Praxis
H1 H2 H3 3 3 1 4 2 1 8 K1 K2 K3 K4 K5

15 1) Beispiel aus der Praxis
H1 H2 H3 3 3 1 4 2 1 8 K1 K2 K3 K4 K5

16 1) Beispiel aus der Praxis
H1 H2 H3 3 4 8 K1 K2 K3 K4 K5 Käufer 1 kauft Haus 1 Käufer 2 kauft Haus 2 Käufer 4 kauft Haus 3  Maximaler Gewinn für Makler durch maximales Matching

17 2) Algorithmus: Maximales Matching
Geg.: Beliebiges Matching M in G Alle Kanten in M: dunkle Kanten Alle Kanten in E\M: helle Kanten P = M-erweiternder Weg (D.h. erste und letzte Kante von P ist hell) m dunkle Kanten, m+1 helle Kanten jjjjj

18 2) Algorithmus: Maximales Matching
Idee: Neues Matching M‘ durch Umfärben entwickeln M‘-Entwicklung: Alle dunklen Kanten in P ersetzen durch die m+1 hellen Kanten in P  M‘ ist neues Matching (eine Kante mehr)

19 2) Algorithmus: Maximales Matching
v1 v2 v3 v4 e1 e2 e3 a e4 e6 e7 e5 e10 e9 e8 v6 v7 v8 v5 M = {e4, e6, e7} P = {v5, v6, v1, v2, v7, v8, v3, v4}

20 2) Algorithmus: Maximales Matching
v1 v2 v3 v4 e1 e2 e3 a e4 e6 e7 e5 e10 e9 e8 v6 v7 v8 v5 e8  rot, e4  schwarz

21 2) Algorithmus: Maximales Matching
v1 v2 v3 v4 e1 e2 e3 a e4 e6 e7 e5 e10 e9 e8 v6 v7 v8 v5 e1  rot, e6  schwarz

22 2) Algorithmus: Maximales Matching
v1 v2 v3 v4 e1 e2 e3 a e4 e6 e7 e5 e10 e9 e8 v6 v7 v8 v5 e10  rot, e7  schwarz

23 2) Algorithmus: Maximales Matching
v1 v2 v3 v4 e1 e2 e3 a e4 e6 e7 e5 e10 e9 e8 v6 v7 v8 v5 e3  rot

24 2) Algorithmus: Maximales Matching
v1 v2 v3 v4 e1 e2 e3 a e4 e6 e7 e5 e10 e9 e8 v6 v7 v8 v5 Algorithmus beendet Maximales Matching M‘ = {e8, e1, e10, e3}

25 3) Das Personal-Zuteilungsproblem
Geg.: Paarer Graph G mit V(G) = X U Y Menge X = {x1, ... ,xn} := Lehrer Menge Y = {y1, ..., yn} := Klassen Bei Qualifikation von xi  Kante zu yi Ziel: Matching in G, sodass jedes xi gesättigt wird Realisierung durch Ungarischen Algorithmus

26 3) Ungarischer Algorithmus
Ungarische Mathematiker D.König und J.Egerváry Benötigt werden: Graph G mit 2 Teilmengen X und Y Matching M in G M-alternierender Baum mit Wurzel x0  Um M-erweiternden Weg zu erkennen

27 3) Ungarischer Algorithmus
b1 b2 b3 b4 b5 b6 b7 Matching M = {a1-b2; a3-b3; a5-b4, a6-b7}

28 3) Ungarischer Algorithmus
b1 b2 b3 b4 b5 b6 b7 Knotenmenge S: Aktueller und besuchte Knoten in X Knotenmenge N(S): Nachbarknoten von Knoten in X Knotenmenge T: besuchte Nachbarknoten in Y

29 3) Ungarischer Algorithmus
b1 b2 b3 b4 b5 b6 b7 baum Baum B: (1): Beginne mit Matching M (gestrichelt) (2): x0 = a2 ist M-ungesättigt in X  Setze S = {a2} und T = Ø a2

30 3) Ungarischer Algorithmus
b1 b2 b3 b4 b5 b6 b7 Baum B: (3): N(S) = {b2, b3} (4): y = b2 ist M-gesättigt  S = {a1, a2} ; T = {b2} a1 b2 a2

31 3) Ungarischer Algorithmus
b1 b2 b3 b4 b5 b6 b7 Baum B: (5): N(S) = {b2, b3} (6): y = b3 ist M-gesättigt  S = {a1, a2, a3 } ; T = {b2, b3} a1 a3 b2 b3 a2

32 3) Ungarischer Algorithmus
b1 b2 b3 b4 b5 b6 b7 Baum B: (7): N(S) = {b1, b2, b3, b4, b5, b6} (8): y = b1 ist M-ungesättigt  Jetzt: M-erweiternder Weg P ermitteln und umfärben b1 a1 a3 b2 b3 a2

33 3) Ungarischer Algorithmus
b1 b2 b3 b4 b5 b6 b7 Baum B: b1 (9): P = {a2, b3, a3, b1}  Umfärbung entlang P a1 a3 b2 b3 a2

34 3) Ungarischer Algorithmus
b1 b2 b3 b4 b5 b6 b7 Baum B: b1 Nach Umfärbung entsteht neues größeres Matching M a1 a3 b2 b3 a2

35 3) Ungarischer Algorithmus
b1 b2 b3 b4 b5 b6 b7 Baum B: (1): x0 = a4 ist M-ungesättigt in X  Setze S = {a4} und T = Ø a4

36 3) Ungarischer Algorithmus
b1 b2 b3 b4 b5 b6 b7 Baum B: (2): N(S) = {b2, b3, b4, b7} (3): y = b2 ist M-gesättigt  S = {a1, a4} ; T = {b2} a1 b2 a4

37 3) Ungarischer Algorithmus
b1 b2 b3 b4 b5 b6 b7 Baum B: (3): N(S) = {b2, b3, b4, b7} (4): y = b3 ist M-gesättigt  S = {a1, a2, a4} ; T = {b2, b3} a1 a2 b2 b3 a4

38 3) Ungarischer Algorithmus
b1 b2 b3 b4 b5 b6 b7 Baum B: (5): N(S) = {b2, b3, b4, b7} (6): y = b4 ist M-gesättigt  S = {a1, a2, a4, a5} ; T = {b2, b3, b4} a1 a2 a5 b2 b3 b4 a4

39 3) Ungarischer Algorithmus
b1 b2 b3 b4 b5 b6 b7 Baum B: b6 (7): B6  in N(S) (8): N(S) = {b2, b3, b4, b6, b7} (9): y = b6 ist M-ungesättigt a1 a2 a5 b2 b3 b4 a4

40 3) Ungarischer Algorithmus
b1 b2 b3 b4 b5 b6 b7 Baum B: b6  Jetzt: M-erweiternder Weg P ermitteln und umfärben a1 a2 a5 b2 b3 b4 a4

41 3) Ungarischer Algorithmus
b1 b2 b3 b4 b5 b6 b7 Baum B: b6 (10): P = {a4, b4, a5, b6}  Umfärbung entlang P a1 a2 a5 b2 b3 b4 a4

42 3) Ungarischer Algorithmus
b1 b2 b3 b4 b5 b6 b7 Baum B: b6 Nach Umfärbung entsteht neues größeres Matching M a1 a2 a5 b2 b3 b4 a4

43 3) Ungarischer Algorithmus
b1 b2 b3 b4 b5 b6 b7 Baum B: (1): x0 = a7 ist M-ungesättigt in X  Setze S = {a7} und T = Ø a7

44 3) Ungarischer Algorithmus
b1 b2 b3 b4 b5 b6 b7 Baum B: (2): N(S) = {b2, b3} (3): y = b2 ist M-gesättigt  S = {a1, a7} ; T = {b2} a1 b2 a7

45 3) Ungarischer Algorithmus
b1 b2 b3 b4 b5 b6 b7 Baum B: (4): N(S) = {b2, b3} (5): y = b3 ist M-gesättigt  S = {a1, a2, a7} ; T = {b2, b3} a1 a2 b2 b3 a7

46 3) Ungarischer Algorithmus
b1 b2 b3 b4 b5 b6 b7 Baum B: (6): N(S) = {b2, b3} = T = {b2, b3} Algorithmus beendet a1 a2 b2 b3 a7

47 3) Ungarischer Algorithmus
b1 b2 b3 b4 b5 b6 b7 Baum B: G beinhaltet kein Matching, durch das jeder Knoten in X gesättigt wird a1 a2 b2 b3 a7

48 4) Zusammenfassung Matching M: Wozu Matchings? Algorithmen:
Untermenge M von E heißt Matching von G, wenn keine 2 Kanten aus M adjazent sind Wozu Matchings? Personal-Zuteilungs-Problem Algorithmen: Maximales Matching Ungarischer Algorithmus

49 Fragen?


Herunterladen ppt "Matchings (Paarungen) in Graphen"

Ähnliche Präsentationen


Google-Anzeigen