Minimum Cost Matchings

advertisement
OR 215
Network Flows
Spring 1998
M. Hartmann
NON-BIPARTITE MATCHING PROBLEMS
Application: Odd and Even Paths
Augmenting Path Approach
Cardinality Matchings
Minimum Cost Matchings
Geometric Duality
APPLICATION: ODD AND EVEN PATHS
If G is an undirected network and cij  0 for all arcs (i,j),
then we can replace each undirected arc by a pair of
directed arcs and use Djikstra’s algorithm to find a shortest
path from s to t.
 What if we want to find the shortest path from
s to t with an even number of arcs?
1
s
2
3
1
1
4
3
2
2
2
1
2
1
3
2
This can be formulated as a minimum cost perfect
matching problem in a layered graph.
t
1
s
2
3
1
4
1
3
2
2
1
0
3
0
2
0
0
2
0
3
0
4
3
2
2
2
1
2
1
3
2
t
A minimum cost perfect matching.
This construction does not work when some costs are
negative (why?). A similar construction can be used to
find shortest paths with an odd number of arcs.
AUGMENTING PATH APPROACH
An augmenting path is an alternating path that starts and
ends at an unmatched node.
Proposition: If M is a matching and P is an augmenting
path, then M  P is a matching of cardinality |M|+1. All
matched nodes in M remain matched in M  P.
 M  M  P is called an augmentation.
Theorem. If a node p is unmatched in a matching M,
and there is no augmenting path starting at p, then p is
unmatched in some maximum matching.
p
q
CARDINALITY MATCHING ALGORITHM
algorithm CARDINALITY MATCHING;
begin
M :=  ;
for each unmatched node p  N do
if there is an augmenting path P starting at p
then augment M  M  P
else delete p and its incident arcs from G;
end
To find an augmenting path, grow a tree T of alternating
paths rooted at p, labelling each node “odd” or “even”.
E
O
E
O
E
O
E
O
E
O
E
root
 Does this labelling procedure always find an
augmenting path when there is one?
BLOSSOMS
E
O
E
O
E
O
E
O
E
O
E
root
A flower (with respect
to a matching M and a root p)
has two components:
 A stem is an even alternating path strarting at the root p
and ending at a node w (an empty stem has w = p).
 A blossom is an odd alternating cycle that starts and
ends at its base w -- the end node of a stem -- and has
no other node in common with the stem.
stem
E
root
O
E
base
blossom
CONTRACTING A BLOSSOM
Proposition: There is an even alternating path from the
root node p to each node in the blossom, which ends at a
matched node.
E
O
E
blossom
root
If the blossom B = i1-i1--ik-i1, then we introduce a
pseudonode b in the contracted graph Gc with
A(b) = A(i1)  A(i1)    A(ik)
and set A(j) = A(j)  { b } for each node j  A(b).
E
root
O
E
pseudonode representing
the contracted blossom B
CORRECTNESS
Let Mc be the matcing in the contracted graph. The
property implies that no new augmenting paths (with
respect to Mc) are created in Gc.
Lemma. If the contracted graph Gc contains an augmenting path starting at the root node p (or the pseudonode
containing p) with respect to the matching Mc, then the
original graph contains an augmenting path starting at p
with respect to M.
The correctness of the non-bipartite cardinality matching
algorithm follows because the converse is also true:
Lemma. The contracted graph Gc contains an augmenting path starting at the root node p (or the pseudonode
containing p) with respect to the matching Mc, only if the
original graph contains an augmenting path starting at p
with respect to M.
EXAMPLE
A maximal matching with an unmatched node.
O
E
O
contracted
graph Gc
O
O
E
O
contracted
graph Gc
O
E
O
contracted
graph Gc
E
O
EXPANDING THE PSEUDONODES
The augmenting path in the original graph.
A maximum (perfect) matching.
DATA STRUCTURES
What kind of data structures do we need to
 identify a blossom?
Pred()
 shrink a blossom?
Active()
 expand a blossom?
doubly-linked list of
blossom vertices or
pseudovertices
RUNNING TIME
Each of O(n) searches for augmenting paths requires:
Labeling Procedure:
O(n) per vertex, O(n2) total
Number of contractions:
O(n) – net loss of two nodes
Time for contracting:
O(n) per vertex, O(n2) total
Time for expanding:
O(n) per pseudonode
Total Running Time:
MAXIMUM WEIGHT MATCHING
An integer programming formulation is
maximize
wijxij
subject to
 j xij

xij  0
for all i  N
 1
for all (i,j)  A
xij integer
for all (i,j)  A
 Can we drop the integrality constraints?
1
7
4
2
9
8
5
6
3
 How many matching edges can there be in an odd set?
A linear programming formulation for the maximum weight
matching problem is
maximize
wijxij
subject to
 j xij

 1
 i,jU xij

xij  0
for all i  N
 |U|/2
for all U  N
with |U| odd
for all (i,j)  A
This leads to optimality conditions for the maximum weight
matching problem involving node prices j and dual prices
yU for each such odd set U  N.
The maximum weight non-bipartite matching problem can
also be solved by a primal-dual algorithm in O(n S(n,m,C))
time. As in the successive shortest paths algorithm, if an
augmenting path cannot be found, a dual change is made.
Although there are exponentially many odd sets, the only
ones with positive dual prices correspond to peudonodes.
MINIMUM COST PERFECT MATCHING
The minimum cost perfect matching problem can be
solved as a maximum weight matching problem with
weights wij = M - cij.
A linear programming formulation is
minimize
subject to
cijxij
 j xij = 1
 iU, iU xij
for all i  N

 1

xij  0
for all odd sets U
for all (i,j)  A
If we identify the odd sets U and N\U, the dual LP is
maximize
 jN j +  U  N, |U| odd yU
subject to
i + j + iU, iU yU  cij for all arcs (i,j)

yU  0

for all odd sets U
When the costs cij satisfy the triangle inequality, there is
always a dual solution withj  0 for all j  N.
GEOMETRIC DUALITY
When the costs cij are just the Euclidean distance between
points i and j, the dual LP has a geometric interpretation.
The node prices j are the radii of control zones around
the points j, and the dual prices yU are the width of moats
around the set of points in U.
moat
control zone
For a disjoint packing of moats and control zones, any
perfect matching must cover at least the sum of the radii of
the control zones and the width of the moats (which is the
dual objective value).
 In this setting, what is a geometric interpretation
of complementary slackness?
Download