Matching. Applications Cover

Given a , G = (U,V ,E), with edge weights w : E R, → Given a bipartite graph, G = (U,V ,E), with edge weights w : E R, find an function of minimum total value. → find a maximum weight . A function p : V R, where for all edges, e = (u,v) Jobs to workers. → A matching is a set of edges where no two share an endpoint. p(u) + p(v) w(e). Teachers to classes. ≥ u a Minimize ∑v U V p(u). Blue – 3. Green - 2, Classes to classrooms. ∈ ∪ 320 u a 103 Black - 1, Non-edges - 0. v b “The ” Solution Value: 12. Solution Value: 7. Min Weight Matching. 130 v b 103 Solution Value: 12. w c Solution Value: 7. Negate values and find maximum weight matching. 130 w c 103 Solution Value: 9. Solution Value: 8. x d Solution Value: 8. 230 x d 203

Cover is upper bound. Simple example. Maximum Matching

Feasible p( ), for edge e = (u,v), p(u) + p(v) w(e). · ≥ Given a bipartite graph, G = (U,V ,E), find a maximum sized w(e) Blue edge – 2, Others – 1. matching. u v 1 a x 0 Using max incident edge. Key Idea: Augmenting Alternating Paths. p(u) p(v) 2 b y 0 Example: Value: 3. For a matching M, each u is the endpoint of at most one edge in M. Using max incident edge. a x u 0 a x 1 Value: 2. Same as optimal matching! y w(e) (p(u) + p(v)) p(u) + p(v) 1 b 0 Proof of optimality. ∑ ≤ ∑ ≤ ∑ ∑ b y e=(u,v) M e=(u,v) u U v V Matching and cover are optimal, ∈ ∈ ∈ edges in matching have w(e) = p(u) + p(v). Tight edge. Start at unmatched node(s), Holds with equality if all nodes are matched. follow unmatched edge(s), for e M, w(e) = p(u) + p(v) (Defn: tight edge.) and follow matched. ∈ . Repeat until an unmatched node. No perfect matching Back to Maximum Weight Matching. Maximum Weight Matching Goal: perfect matching on tight edges.

a x Can’t increase matching size. Algorithm No alternating path from (a) to (y). Start with empty matching, feasible cover function (p( )) · Cut! Add tight edges to matching. Use alt./aug. paths of tight edges. Still no augmenting path. Want vector cover (price function) p( ) and matching where. p( ) + δ b y · · ”maximum matching algorithm.” Still Cut? Optimal solutions to both if p( ) . . · . . No augmenting path. Use directed graph! for e M, w(e) = p(u) + p(v) (Defn: tight edge.) and . ∈ .. p( ) Cut, (S,T ), in directed graph of tight edges! Cut in this graph. perfect matching. · . All edges across cut are not tight. (loose?) p( ) δ . c z · − Nontight edges leaving cut, go from SU , TV .

Lower prices in SU , raise prices in SV , Algorithm: all explored edges still tight, Given matching. backward edges still feasible Direct unmatched edges U to V , matched V to U. Find path between unmatched nodes on left to right. (BFS, DFS). ... and get new tight edge! What’s delta? w(e) > p(u) + p(v) Until everything matched ... or output a cut. → δ = mine (S T )w(e) p(u) p(v). ∈ U × V − − Some details Example

Add 0 value edges, so that optimal solution contains perfect matching. 3 u a 10 u X a Beginning “Matcher” Solution: M = . {} 213 v b 0 v b Feasible! Value = 0. Lecture 2 ended in the middle of the previous slide. 213 w c 0 w c A question was asked why don’t we just drop prices around the Beginning “Coverer” Solution: p(u) = maximum incident blue (loose) edge in the figure. Why not? edge for u U, 0 otherwise. ∈ 23 x d 0 x d Main Work: breadth first search from unmatched nodes finds cut. All matched edges tight. Update prices (find minimum delta.) Perfect matching. Feasible price function. Values the same. Optimal! Simple Implementation: Each bfs either augments or adds node to S in next cut. Notice: O(n) iterations per augmentation. no weights on the right problem. O(n) augmentations. retain previous matching through price changes. retains edges in failed search through price changes. O(n2m) time.