1 / 57

Assignments and matchings

Assignments and matchings. Chapter 12 Presented by Yorai Geffen. Overview. Definitions Bipartite ( דו צדדי ) cardinality matching problem Bipartite weighted matching problem Stable Marriage Problem Nonbipartite cardinality matching problem Bipartite Matching Algorithm

marlin
Download Presentation

Assignments and matchings

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Assignments and matchings Chapter 12 Presented by Yorai Geffen

  2. Overview • Definitions • Bipartite (דו צדדי) cardinality matching problem • Bipartite weighted matching problem • Stable Marriage Problem • Nonbipartite cardinality matching problem • Bipartite Matching Algorithm • Nonbipartite Matching Algorithm • Summary

  3. Definitions • Matching: Subgraph with the property that every node in the subgraph has degree zero or one. • Simple Network:Every node in the network, except the source (s) and sink (t) nodes, has at most one incoming arc or at most one outgoing arc.

  4. Bipartite cardinality matching problem • Bipartite matching problem: Given undirected graph . Our target to find a matching with maximum edges. • We transform it to a maximum flow problem

  5. Transformation to max flow problem • Direction: Pointing nodes in to nodes in • New nodes: • New edges: points to all nodes in and all nodes in points to • Capacity: Each arc in the network • Simple network: One incoming arc to , one outgoing arc from

  6. Solution and time complexity • Matching of cardinality k in = flow of value k in • Proof on board… • The unit capacity maximum flow algorithm establishes a maximum flow in unit capacity simple networks in time. [Chapter 8, Theorem 8.2, page 254]

  7. Bipartite weighted matching problem AKA The Assignment Problem • Bipartite network , with • Arc weights • If directed, require • If undirected, make it directed from to

  8. Transformation to min cost flow • Objective function: • Possible solutions: Successive Shortest Path Algorithm, Hungarian Algorithm, Relaxation Algorithm, Cost Scaling Algorithm

  9. Successive Shortest Path Algorithm • Reminder: Augments shortest paths from a node with excess supply to a node with unfulfilled demand. • Time: where is the upper bound of the supply, and denotes the time needed to solve a shortest path problem with nonnegative arc costs bounded by . • Applied on the matching problem, each iteration augments 1 unit of flow assigning to one node in

  10. Relaxation Algorithm • Relaxed constraints: Allows any node in to be assigned multiple times. • Assign to with min cost • In each iteration, choose over-assigned node in run shortest path in residual network, update potentials and augment path to an unassigned node . • Each assigns one more node in , and never makes more unassigned, so within iterations it will end to a feasible assignment. • Maintains optimality conditions. • Overall time:

  11. Stable Marriage Problem • men and women. • Each man ranks each woman by perference and vice versa (high means favored). • A (man,woman) pair is unstable if they’re not married, but prefer each other • A perfect matching (marriage) is stable if it does not contain any unstable pairs.

  12. Stable Marriage Problem cont. • Input: Two preferences matrices. • W.L.O.G we assume each rank is an integer between 1 to . • We use the matrices to construct priority list for each person (decreasing order). Can be constructed in time.

  13. Stable Marriage iterative greedy algorithm AKA Propose-and-reject Algorithm • LIST = • m.current_woman = m’s top priority • Until LIST = do: • For each m in LIST: • mproposes to w = m.current_woman • If w is unassigned and not engaged, then she’s now engaged to m. • If w is engaged, she chooses her preferred one and rejects the other • Rejected man r chooses the next on his priority list to be r.current_woman • Add\Remove man from LIST accordingly to engaged\rejected

  14. Analysis • Correctness: On board. • Complexity: • At each iteration, a woman receiving a proposal: either (1) receiving her first proposal (once per woman), (2) rejects some proposal (at most times). Therefore steps per woman. • In total, steps ( women). • Cannot be better: it is linear in the input data length.

  15. Comments • There could be several stable matchings. • A pair (i,j) is stable partners if some stable match matches man i with woman j. • Algorithms property: Each man obtains his best possible stable partner. • We refer to such a matching as man-optimal.

  16. Man-optimal proof (1) • Lemma: In the propose-and-reject algorithm, a woman never rejects a stable partner. • Proof: • the constructed matching by the algorithm. • Suppose the lemma is false. • The first time a woman rejects a stable partner. • Continue on board…

  17. Man-optimal proof (2) • Lemma:The propose-and-reject algorithm constructs a man-optimal stable matching. • Proof: • Immediate after the previous lemma: • The preferred stable-partner of a man will not reject him, as by previous lemma.

  18. Nonbipartitecardinality matching problem – notations(1) • – a node’s adjacency list • A matching of graph is a subset of arcs with the property that no two arcs of are incident to the same node • The arcs of are matched arcs, while the others are unmatched arcs. • Nodes incident to matched arcs are matched nodes, else unmatched.

  19. Nonbipartite cardinality matching problem – notations(2) • A path is an alternating path in if every consecutive pair of arcs in the path contains one matched and one unmatched arc. • Odd\Even alternating path – as the number of arcs in the path. • Alternating Cycle is an alternating path which starts and finishes on the same node.

  20. Nonbipartite cardinality matching problem – notations(3) • Augmenting path– odd alternating path where the first and last nodes in the path are unmatched. • By switching the matches we augment the cardinality by 1. • Symmetric difference of sets -

  21. Properties (1) • If is a matching and is an augmenting path in , then is a matching of cardinality + 1. Moreover, in the matching, all the matched nodes in remain matched and two additional nodes, namely the first and last nodes of P, are matched. (augmentation) • Explanation:

  22. Properties (2) • If and are two matchings, their symmetric difference defines the subgraphwith the property that every component is one of the six types shown here:

  23. Augmenting Path Theorem • Theorem: If a node p is unmatched in a matching M, and this matching contains no augmenting path that starts at node p, then node p is unmatched in some maximum matching. • Proof: • Let be a maximum matching. Assume p matched in , otherwise done. • Look at One of six figures. Yet p is unmatched in , so only (d) and (e) are possible, when p is the starting node on the left. • No augmenting path rules out (d). So must be (e). • also maximum matching and p is unmatched. • Thus such a maximum matching exists.

  24. Bipartite Matching Algorithm • is a maximum matching, by the previous theorem. • At each iteration, number of unmatched nodes reduces by 1 (either by matching or deleting).

  25. Finding an augmenting path from node p • Search algorithm to identify all reachable nodes by alternating paths from p. If it finds an unmatched node reachable from p, we found the path. Else it does not exist. • Complicated: Straight forward solves it for bipartite case, but it fails for thenonbipartite case.

  26. The straightforward approach • Search tree from p to others via alternating path. • p – the root node (remember: p is unmatched) • The search tree – an alternating tree. • Nodes in the alternating tree – labeled, else unlabeled. Each labeled node is even or odd depending on the unique path from p. • If odd and unmatched – it is an augmenting path. • LIST of labeled nodes, examined one by one. • Assign label to its adjacencies (if unlabeled).

  27. Example

  28. Complexity • Time: • Search and augment executed at most n times • Augment takes time. • Search takes time. • Examining an odd node takes – just the matching arc. • Examining an even node takes , all its neighbors.

  29. Search algorithm

  30. Correctness of the search method • If we find an augmenting path, it exists. • If we fail to find, can we conclude one does not?

  31. Unique label property • A graph is said to possess a unique label property with respect to a given matching and a root node p if the search procedure assigns a unique label to every labeled node (i.e., even or odd) irrespective of the order in which it examines labeled nodes. • Use: If a graph poses this property, then if an augmenting path exists, the search will find it. • Proof: Take an augmenting path, label in its order. So all other orders should be labeled the same.

  32. Unique label property cont. • Bipartite networks satisfy this property. • If the root is in then every labeled node in will receive an even label, and every labeled node in will receive an odd label. • This is why the algorithmworks in bipartite networks. • Nonbipartite networks might not satisfy the unique label property, and therefore the search algorithm might fail to detect an augmenting path even though the network contains one.

  33. Nonbipartitenetwork counter example • Path 1-2-3-4-5 6 is given odd Augmenting path • Path 1-2-3-7-8-5 6 is not even scanned (not part of a unique matched arc to 5). Thus the algorithm fails. • We can connect node 5 to the root by both an odd-length and an even-length alternating path.

  34. Solution? • Allow nodes to have both an even and odd labels, and scan it accordingly. • Fails:

  35. Difficulty • By assigning just one label to each node, we might overlook an augmenting path. • By assigning two labels, we might falsely believe that we have found an augmenting path. • Why? What is the cause? • Certain subgraphs called flowers, composed of particular types of paths and odd cycles.

  36. Flowers and Blossoms • A flowerin respect to a matching and a root node p, is a subgraph with two components: • Stem – An even length alternating path that starts at p and terminates at some node w. If p = w, we say that the stem is empty. • Blossom – An odd length alternating cycle that starts and terminates at the terminal node w of a stem, and has no other node in common with the stem. We refer to node w as the base of the blossom.

  37. Properties (1) • A stem spans 2i nodes and contains i matched arcs for some integer i 0. • A blossom spans 2k + 1 nodes and contains k matched arcs for some integer k 1. The matched arcs match all nodes of the blossom except its base. • The base of a blossom is an even node.

  38. Properties (2) • Every node i in the blossom (except its base) is reachable from the root p (or from the base of the blossom w) through two distinct alternating paths; one has even length and the other has odd length.

  39. Even nodes in blossom • In a blossom – each node can receive both even and odd labels. • We would prefer to give even labels to the nodes for the following reason: • Even-labeled nodes - we can label nodes outside the blossom (all unmatched arcs incident to nodes in the blossom). • Odd-labeled nodes - we label only the nodes in the blossom (matched arcs).

  40. Intuition • If we assign all nodes in a blossom with even, the search algorithm will find an augmenting path. • All nodes in blossom are matched, except its base. • Can be reached with either an even or odd path. • If stem is not empty – the base is matched too.

  41. Contracting a blossom (1) • Popular approach: Shrink blossom to single node. • Blossom B = turns to a node b (pseudonode – always even): • Neighbors: • Update neighbors: • To recover information we form a circular doubly linked list of its nodes, and deleted them and all their arcs from the network (another update).

  42. Contracting a blossom (2) • The result network the contracted network.

  43. Nonbipartite Matching Algorithm • Search procedure assigns even or odd labels. • Algorithm will identify the possibility to assign even\odd to an odd\even respectively. • When discovering we can assign different label than what node i already has, we suspend the search. Trace back the indices of these paths until the first common node. That node is the base, and the nodes traced are the blossom. • Then we contract it to a pseudonode. • If we find a path containing a pseudonodes, we expand them one by one until none are in the path (pseudonode can contain other pseudonodes)

  44. Algorithm (1)

  45. Algorithm (2)

  46. Example - Finding

  47. Example - expanding

  48. Correctness (1) • Lemma, If contains an augmenting path starting at the root node p (or the pseudonode containing p) with respect to the matching, then the original network contains an augmenting path starting at the root p with respect to the matching . • Proof: • If does not contain a node b, then is valid in .

  49. Correctness (2) • Lemma,if contains an augmenting path from node p to node q with respect to a matching , then contains an augmenting path from node p (or the pseudonode containing p) to node q with respect to the matching . • Proof: • P in from p to q. Only unmatched nodes in . • If P has not node in common with a Blossom B, then P is also a path in the contracted network – nothing to prove. So assume it has nodes in common. • Case 1 – stem is empty:

  50. Correctness (2) cont. • Proof (cont.): • Case 2 –B has nonempty stem. • - even alternating path from p to w (base of B). • - p matched, w unmatched. • contains augmenting path in so in too. w,q are the only unmatched nodes in , so must contain an augmenting path between them. • matching of contracted graph in respect to . • In , B has an empty stem, so case 1 applies, and we have an augmenting path after contracting the nodes of the blossom. • So contains an augmenting path with respect to the matching . But since and have the same cardinality, must also contain an augmenting path with respect to the matching . This conclusion completes the proof of the lemma.

More Related