Document 10622843

advertisement
Maximum Matchings via the Tu1e Matrix Eli Ross April 29, 2013 18.304: Seminar in Discrete Math IntroducBon •  Bipar&te graph: Two sets of verBces (we take both to have size n) such that there is no edge within the same set. •  Matching: A set of edges chosen in a graph such that no vertex is the endpoint of two or more edges. •  Perfect Matching: A matching which contains every vertex as an endpoint of some edge in the matching. Problem •  We want to answer the quesBon: Does an unweighted, undirected graph (bipar&te or general) G admit a perfect matching? (If so, find one.) •  We turn to matrices and randomized algorithms to help answer this quesBon. Outline •  Refreshing Old Topics (Lin. Alg, PermutaBons) •  A First AUempt (Naïve Algorithm) •  Schwartz-­‐Zippel Lemma for Polynomial Equality •  Good Method for BiparBte Graphs •  Refinement for General Graphs •  Discussion and Comparison Recall… n
⎛
⎞
•  det
( A ) = ∑
⎜ sgn (π ) ⋅ ∏
aiπ (i) ⎟ where S n is the set ⎠
i=1
π ∈Sn ⎝
of all permutaBons of { 1,
2,…,
n } and ⎧⎪ 1 if even number of transpositions
sgn (π ) = ⎨
⎪⎩ −1 if odd number of transpositions
•  All permutaBons can be wriUen in terms of cycles •  A biparBte matching is essenBally a permutaBon Preliminary Idea •  Define A as follows: ⎧⎪ 1
aij = ⎨
⎪⎩ 0
if i ~ j, i ∈U, j ∈V
otherwise
•  Claim: If det
( A ) ≠ 0,
then G has a perfect matching. Claim: If det
( A ) ≠ 0,
then G has a perfect matching. •  Recall that: n
⎛
⎞
det ( A ) = ∑ ⎜ sgn (π ) ⋅ ∏ aiπ (i) ⎟
⎠
i=1
π ∈Sn ⎝
•  If determinant is nnon-­‐zero, then there must be some non-­‐zero ∏
a iπ (i ) term, so a perfect i=1
matching exists. (Why?) •  A quick example might help you believe me! How Good Is This? •  CompuBng the determinant of this matrix will take (
O n
2.376
)
via the Coppersmith-­‐Winograd algorithm. (PreUy impracBcal, so actual runBme is probably worse.) •  However, what’s the big problem here? A BeUer Matrix! •  Define B as follows: ⎧⎪ xij
bij = ⎨
⎪⎩ 0
if i ~ j, i ∈U, j ∈V
otherwise
•  Claim: det
( B ) ≠ 0 if and only if G has a perfect matching. (We’ll come back to this.) TesBng Polynomial Equality •  QuesBon: does f ( x ) =
g ( x ) ? How could we tell without actually finding the polynomials? •  Idea: subsBtute random values from {1, 2,…, mn}
and see if the result is 0, where deg ( f ( x )), deg ( g ( x )) ≤ n.
Probability of Failure •  The most roots of f ( x ) − g ( x ) in { 1, 2,…,
mn
} is n. Hence, the probability of failure if we do this procedure k Bmes is: 1
k
m
so the probability of success is at least 1
1− k .
m
Schwartz-­‐Zippel Lemma Claim. If F
≠ 0 is a polynomial in ( x1, x2 ,…, xn )
with d i the degree of F ( ⋅ ) in x i and I n ) are finite subsets of elements in ( I 1 , I 2 ,…,
the domain of each variable, then the number of roots of F
in I 1 ×
I 2 ××
I n is at most: ⎛ n di ⎞ n
⎜ ∑ I ⎟ ⋅ ∏ Ii
⎝ i=1 i ⎠ i=1
Claim. Schwartz-­‐Zippel Lemma •  Proceed via inducBon. Base case is clear. •  Let F ' be the polynomial in ( x 2 ,…,
x n ) and suppose that ( y2 ,…, yn ) is not a zero of F '. Then F
( x 1, y 2 ,…,
yn ) has at most d 1 zeros. •  It follows that the number of roots cannot exceed n
⎛ ⎛ n di ⎞ n
⎞
d1 ⋅ ∏ I i + ⎜ ⎜ ∑ ⎟ ⋅ ∏ I i ⎟ ⋅ I1
i=2
⎝ ⎝ i=2 I i ⎠ i=2 ⎠
Refresher… •  Define B as follows: ⎧⎪ xij
bij = ⎨
⎪⎩ 0
if i ~ j, i ∈U, j ∈V
otherwise
•  Claim: det
( B ) ≠ 0 if and only if G has a perfect matching. Claim: det
( B
) ≠ 0 if and only if G has a perfect matching. •  If the determinant i
s n
on-­‐zero, t
here m
ust b
e n
some b term that is non-­‐zero. ∏
i=1
iπ (i )
•  If there is a perfect matching, set those variables to 1 and the others to 0. Then, the determinant is not idenBcally zero. Now what? •  CompuBng the determinant is annoying. How would we combine terms, etc.? •  Instead, turn to randomized algorithm: -­‐ choose the x ij randomly from {1,…, n 2 m}
-­‐ compute det ( B )
-­‐ if determinant is 0, conBnue this process unBl some confidence threshold is hit How good is that? •  Via Schwartz-­‐Zippel, there are at most ⎛
1 ⎞
1
2
2
⋅
n
m
=
⋅
n
m
∏
⎜ ∑ n2m ⎟ ∏
m i=1
⎝ i=1
⎠ i=1
n2
n2
(
)
n2
(
)
roots of F ( x11 ,…,
x nn ) on {1,…,
mn } . Hence, the probability of making an error is 2
2 n
1
.
m
Probability of Success and RunBme •  It follows that with k repeBBons, we can say that we make an error in classificaBon with probability at most 1
mk
2.376
•  The runBme of the determinant is O
( n ) and more pracBcal methods could be worse. •  What about general graphs? The TuUe Matrix •  Define T as follows (why?): ⎧ xij if i ~ j and i > j
⎪⎪
tij = ⎨ −x ji if i ~ j and i < j
⎪
otherwise
⎪⎩ 0
•  Claim: det
( T ) ≠ 0 if and only if G has a perfect matching. Claim (i): If G has a perfect matching, then det (T ) ≠ 0
•  Take a perfect matching M; for each pair ( i, j ) we set x ij = 1 if (i, j ) ∈M
and
i > j and otherwise set xij = 0.
•  Take π to be a permutaBon such that i = π ( j ) and j = π (i ) for all (i, j ) ∈M
which clearly exists (just swap pairs). n
n
⇒ ∏ tiπ (i) ≠ 0, ∏ tiπ '(i) = 0 ⇒ det (T ) ≠ 0.
i=1
i=1
Claim (ii): If det
( T ) ≠
0 then G has a perfect matching. •  Suppose some π contains an odd cycle ir ) with r odd. Then, consider some σ = (i1, i2 ,…,
π
' with σ ' = (i r , ir−1 ,…,
i1 ) . It follows that n
n
i=1
i=1
sgn (π ) ⋅ ∏ tiπ (i) = −sgn (π ') ⋅ ∏ tiπ '(i)
•  Since the determinant is non-­‐zero, there must be some permutaBon of only even cycles, so there must be a perfect matching. Back to old tricks… •  Turn to randomized algorithm: -­‐ choose the x ij randomly from 1,…, n 2 m
-­‐ compute det
(T )
-­‐ if determinant is 0, conBnue this process unBl some confidence threshold is hit •  With k repeBBons, error w/ probability at most {
(
1
k
m
•  RunBme is again O n 2.376
)
}
That’s PreUy Good •  This algorithm is easy to program (if we don’t want opBmized runBme). •  For biparBte graphs, Hopcroh-­‐Karp gives a runBme of O ( E V ) = O ( n 2.5 ) . •  For general graphs, the Blossom method of Edmond’s was originally O ( V 4 ) = O ( n 4 ) but has been improved to O ( E V ) = O
( n 2.5 ) . •  However, we haven’t found perfect matchings yet… L Finding Perfect Matchings •  First approach: sequenBal algorithm. -­‐ Pick random (i, j ) ∈G
-­‐ Check if G \ { i, j } has a perfect matching -­‐ If so, put ( i, j ) ∈M
and conBnue on G \ {i, j}
-­‐ Else, conBnue on G − (i, j )
Finding Perfect Matchings •  BeUer approach: parallel algorithm. Won’t go into details (email me for them – it’s preUy cool). -­‐ Pick random weights for edges wi
-­‐ Sekng the x’s to 2 , the min weight matching will be the largest power of 2 dividing the determinant -­‐ Compute matchings by compuBng the determinant in parallel and for each edge, run through a process and output/don’t output the edge. ResulBng output edges make that min weight maximum matching if one exists. How Good Are Those? •  The first one is slow. (How slow?) •  The second one is good. It’s the same as finding if a perfect matching exists, assuming you can run in parallel. •  The second one succeeds with probability at least ½, so you might need to run it a few (finite) Bmes… •  SBll, the second one with O
( n 2.376
) is a great bound Final Remarks •  This method is easy to implement in code. •  It runs reasonably quickly, especially for finding if perfect matchings exist. Very quickly in the asymptoBc/theoreBcal sense. •  We used randomized algorithms to get very good results. •  There isn’t much difference between biparBte and general graphs here. END 
Download