Lecture 10: Minimum cost perfect matching
1 Definition
- A matching is a set of edges without common vertices. Or, each vertex has a degree ≤ 1 \leq 1 ≤1.
-
G
=
(
V
,
E
)
G=(V,E)
G=(V,E) is a bipartite graph that does not contain any odd-length cycles.
- Assume V V V can be partitioned in to X X X and Y Y Y, such that ∣ X ∣ = ∣ Y ∣ = n |X|=|Y|=n ∣X∣=∣Y∣=n, and each edge has one endpoint in X X X and one endpoint in Y Y Y.
- Assume G G G admits a perfect matching, i.e., a matching of cardinality n n n.
- Want to compute a minimum-cost perfect matching of G G G.
2 Algorithm
2.1 Residual graph
Definition of residual graph G M G_M GM
G M G_M GM is V ∪ { s , t } V \cup \{s,t\} V∪{s,t}, for each vertex x x x in X X X
- if x x x is not matched in M M M, add directed edge ( s , x ) (s,x) (s,x) with cost zero
- if y y y is not matched in M M M, add directed edge ( y , t ) (y,t) (y,t) with cost zero
- for each edge e = ( x , y ) ∈ M e=(x,y)\in M e=(x,y)∈M, G M G_M GM contains a directed edge from y y y to x x x with cost − c e -c_e −ce
- for each edge e = ( x , y ) ∈ E / M e=(x,y)\in E/M e=(x,y)∈E/M, G M G_M GM contains a directed edge from x x x to y y y with cost c e c_e ce
Augmenting paths - Simple directed paths in G M G_M GM
- There is a one-to-one correspondence between (simple) directed
s
−
t
s-t
s−t paths in
G
M
G_M
GM and augmenting paths in
G
G
G w.r.t.
M
M
M.
- Let M ′ M' M′ be a perfect matching of G G G.
- M ⊕ M ′ M\oplus M' M⊕M′ corresponds to a collection of vertex-disjoint alternating paths and cycles in G G G. (it’s easy to see that the symmetric difference induces degree at most 2 on any vertex. And a graph with degree at most 2 has a very simple structure; it can only contain paths and cycles.)
- Since ∣ M ′ ∣ > ∣ M ∣ |M'|>|M| ∣M′∣>∣M∣, this collection includes an augmenting path P P P in G G G w.r.t. M M M.
2.2 Alternating cycles
Simple directed cycles in G M G_M GM - Alternating cycles in G G G
There is one-to-one correspondence between simple directed cycles in G M G_M GM and alternating cycles in G G G w.r.t. perfect matching M M M.
Characterizing Minimum-Cost perfect matchings
M M M is a perfect matching of G G G ↔ \leftrightarrow ↔ no negative-cost cycle in G M G_M GM.
Since each vertex is matched in two perfect matchings M , M ′ M,M' M,M′, thus the symmetric difference M ⊕ M ′ M\oplus M' M⊕M′ result in that each vertex has a degree in {0,2}, thus there cannot be paths (since the beginning and end of vertex of a path has a degree=1).
2.3 Vertex prices and Reduced costs in G M G_M GM
Definition
- Maintain a price p ( v ) p(v) p(v) for each vertex v v v in V + s V+s V+s
- For each edge in
G
M
G_M
GM not incident on
t
t
t
- Each directed edge ( s , x ) (s,x) (s,x) is assigned a reduced cost p ( s ) − p ( x ) p(s)-p(x) p(s)−p(x)
- For each edge
e
=
(
x
,
y
)
e=(x,y)
e=(x,y)
- if e = ( x , y ) ∈ G M e=(x,y) \in G_M e=(x,y)∈GM, reduced cost = c e + p ( x ) − p ( y ) =c_e+p(x)-p(y) =ce+p(x)−p(y)
- if e = ( y , x ) ∈ G M e=(y,x) \in G_M e=(y,x)∈GM, reduced cost = − c e + p ( y ) − p ( x ) =-c_e+p(y)-p(x) =−ce+p(y)−p(x)
Nonnegative reduced costs
- G M G_M GM does not contain any negative-cost directed cycles
- Use Dijkstra’s SSSP algorithm to compute minimum-cost s-t path in G M G_M GM
2. Iterative framework
- From
M
i
M_i
Mi to
M
i
+
1
M_{i+1}
Mi+1, identify an augmenting path
P
i
P_i
Pi and set
M
i
+
1
=
M
i
⊕
P
i
M_{i+1}=M_i \oplus P_i
Mi+1=Mi⊕Pi.
- P i P_i Pi is a simple path in G G G of odd length, with one endpoint in X X X and the other endpoint in Y Y Y.
- Edges of P i P_i Pi alternate between edges in M i M_i Mi and edges not in M i M_i Mi.
- Neither endpoint is matched in M i M_i Mi, so P i P_i Pi begins and ends with an edge that is not in M i M_i Mi.
- The cost of M i + 1 M_{i+1} Mi+1 is equal to the cost of M i M_i Mi plus the cost of s → t s\rightarrow t s→t of P i P_i Pi in G M G_M GM.