COMS 6998 Lec 2
COMS 6998 Lec 2
Disclaimer: This draft may be incomplete or have errors. Consult the course webpage for the most
up-to-date version.
1 Induced Subgraphs
Recap from last lecture. We consider the following problem: Given an n-node input graph G, does
G contain H as an induced subgraph? (see Figure 1)
k k
i j i j
l l
In the last lecture we proposed the following approach: Let A ∈ {0, 1}n×n be the adjacency matrix
of G: (
1 if (i, j) ∈ E(G),
A[i, j] =
0 otherwise.
2
The algorithm first computes A2 ∈ Rn×n in O(n2.373 ) time, then computes the value (i,j)∈E(G) A 2[i,j]
P
in O(n2 ) time. This value counts the number of our target graph in G, but also counts 4-cliques in G:
2
X A [i, j] X
= # of pairs (k, l) s.t. (i, k), (k, j), (i, l), (l, j) ∈ E(G)
2
(i,j)∈E(G) (i,j)∈E(G)
= (# of H) + 6 × (# of K4 ).
Each copy of K4 is counted 6 times since it’s counted once in the summand corresponding to (i, j) being
each of its 6 edges.
A2 [i,j]
P
A randomized algorithm. Denote R(G) := (i,j)∈E(G) 2 .
• If R(G) is not a multiple of 6, then we conclude that G must contain H as an induced subgraph.
1
We repeat this sampling process for 100 times. If for at least one sampled subgraph G0 , R(G0 ) is
not a multiple of 6, then we conclude that the original graph G contains H as an induced subgraph.
The failure probability is Pr[failure] ≤ (15/16)100 < 1/100.
Lemma 1 (Correctness of the randomized algorithm). If the graph G contains at least one induced copy
of the subgraph H, then if we remove every node of G independently with probability 1/2, the resulting
graph will have (# of H) 6≡ 0 (mod 6) with probability at least 1/16.
Proof. Let
X
P (x1 , x2 , · · · , xn ) = xi xj xk xl .
0<i<j<k<l≤n, s.t. nodes i, j, k, l form H in G
1
Pr [P (x) 6≡ 0 (mod 6)] ≥ .
x1 ,x2 ,··· ,xn ∼{0,1} 16
The only missing piece in the previous proof is to show that for a uniformly random Boolean vector
x, the probability that P (x) 6≡ 0 (mod 6) is at least 1/16. We will prove a slightly more general lemma
where the degree of P is any integer d, and the modulus is any integer m > 1.
Lemma 2. If P (x1 , x2 , · · · , xn ) is a multilinear polynomial with integer coefficients which are not all
divisible by m, and P has degree at most d, then
1
Pr [P (x) 6≡ 0 (mod m)] ≥ .
x1 ,x2 ,··· ,xn ∼{0,1} 2d
Before proving Lemma 2, we first prove the following warm-up lemma, which will be used in the proof
of Lemma 2.
2
Proof. The multilinear polynomial P can be written in the form
X Y
P (x1 , x2 , · · · , xn ) = aS · xi ,
S⊆{1,··· ,n} i∈S
where the aS coefficients are integers which are not all divisible by m. Pick a minimum size set T ⊆
{1, 2, · · · , n} such that aT 6≡ 0 (mod m).
Define y ∈ {0, 1}n by (
1 if i ∈ T,
yi =
0 otherwise.
Q
Then for any set S ⊆ {1, 2, · · · , n}, we have i∈S yi = 1 only if S ⊆ T . And since T is the minimum size
set where aT 6≡ 0 (mod m), we have aS ≡ 0 (mod m) for any strict subset S ( T . It follows that
X
P (y) = aS = aT 6≡ 0 (mod m).
S⊆T
Proof of Lemma 2. Again write the multilinear polynomial P in the following form:
X Y
P (x1 , x2 , · · · , xn ) = aS · xi .
S⊆{1,··· ,n} i∈S
Pick any set T ⊆ {1, 2, · · · , n} of maximum size such that aT 6≡ 0 (mod m). Let d0 = |T |. Since P
has degree d, we know that d0 ≤ d. For convenience we re-order the subscripts and denote this set as
T = {1, 2, . . . d0 }.
0
Consider any 0/1 assignment to xd0 +1 , . . . , xn . Let Q : Zd → Z be the resulting polynomial from
this partial assignment to P , where Q has d0 variables x1 , . . . , xd0 . Q is nonzero (mod m) since the
Q
monomial aT · i∈T xi is still in Q. By Lemma 3, there exists an assignment to x1 , . . . , xd0 such that
Q(x1 , . . . , xd0 ) 6≡ 0 (mod m).
Thus, for any 0/1 assignment to xd0 +1 , . . . , xn , there is at least one 0/1 assignment to x1 , . . . , xd0 such
that P (x1 , · · · , xn ) 6≡ 0 (mod m). Hence, as desired,
1 1
Pr [P (x1 , · · · , xn ) 6≡ 0 (mod m)] ≥ 0 ≥ .
x1 ,··· ,xn ∼{0,1} 2 d 2d
P (x, y) = x2 − y 2 − (x + y)(x − y)
3
is the zero polynomial, but for larger examples such as
or
R(x, y, z) = (x + y)100 + (x + z)100 + (y + z)100 − 2(x + y + z)100 ,
it may be unclear. Expanding out all the terms of the polynomial by brute force can be slow. An efficient
test is instead to evaluate the polynomial on a few random points, and check whether the result is always
zero. If the polynomial is zero, then it will always output 0, but otherwise, the next lemma shows that
it will output a nonzero value with decent probability.
Lemma 4 (Schwartz-Zippel). Let F be any field, and let S ⊆ F be a finite subset. Let P (x1 , · · · , xn ) be
a nonzero polynomial over F with degree ≤ d. Then
d
Prn [P (x) = 0] ≤ .
x∼S |S|
Pr[P (x1 , · · · , xn ) = 0] ≤ Pr[Pk (x1 , . . . , xn−1 ) = 0] + Pr[P (x1 , . . . , xn ) = 0 | Pk (x1 , . . . , xn−1 ) 6= 0],
d−k k d
which is at most |S| + |S| = |S| .
4
assumption will be discussed in following classes.
Definition 5 (Matching in a graph). For an undirected graph G with n nodes, a matching is a subset
S of the edges of the graph G such that every node of G is incident to at most one edge of S. A perfect
matching is a matching in which each node of G is incident to exactly one edge of S, or equivalently, a
matching of size n/2.
There is a simple reduction showing that if one can detect whether a graph has a perfect matching
in time T (n), then one can binary search for the maximum size of a matching in a graph in time
O(T (n) log n). (The idea is that, for any k, to test whether G has a matching of size at least (n − k)/2,
one can add k nodes to G which are adjacent to each other and every other node in G, and test whether
the resulting graph has a perfect matching.)
Our goal is to find if a graph has a perfect matching in O(n2.373 ) time, and we will use polynomial
identity testing as discussed above. Our plan is to define a polynomial P such that
1. P (x) 6= 0 if and only if G has a perfect matching, and
The determinant of M , det(M ), is the polynomial we are looking for with degree ≤ n. We are going
to prove that det(M ) 6= 0 if and only if G has a perfect matching.
Assuming this claim is true, our algorithm works as follows: pick a finite field | Fq | > 2n, then evaluate
det(M ) on random points in Fq . By the Schwartz-Zippel Lemma (Lemma 4), after trying a large constant
number of random points, we learn with high probability whether det(M ) is a zero polynomial.
Theorem 7. det(M ) 6= 0 if and only if G has a perfect matching.
Proof. Recall the determinant of the matrix M is given by
X n
Y
det(M ) = sgn(σ) · M [i, σ[i]],
σ∈Sn i=1
where Sn is the set of all the permutations on {1, · · · , n}. To make our discussion easier, we will use fσ
to denote ni=1 M [i, σ[i]]. So we have
Q
X
det(M ) = sgn(σ)fσ .
σ∈Sn
So what is fσ anyways? Think about fσ in terms of a “cycle cover” of G. A cycle cover of a graph is a
cover where all the edges (directed) belong to a cycle or a loop. If you draw all the directed edges out in
5
terms of the permutation σ (all edges have the form (i, σ(i)) with the arrow pointing towards σ(i)), then
fσ = 0 unless all of these edges are in G. This is because if one of the edges you draw is not in G, then
the entry in M corresponding to your edge would have evaluated to be 0, based on how M is defined.
It is not hard to see that if σ has a fixed point (σ(i) = i), then fσ would be 0. Because if σ has a fixed
point, when you draw out the edges defined by σ, you’ll get a self-loop, which is impossible to be in G.
Now, define On ⊆ Sn such that On are permutations that have an odd cycle.
Permutations with odd cycles. We claim that
X
sgn(σ)fσ = 0.
σ∈On
In other words, the terms that corresponds to the permutations in On will cancel each other out in the
calculation of the determinant. Next we prove this claim.
Fix a σ ∈ On . If there is a 1-cycle (a fixed point) in σ, then fσ = 0, as discussed above. If there is no
1-cycle in σ, then we can pick the odd cycle in σ that contains the smallest index. Let σ 0 be σ but with
that cycle reversed. (For instance, if σ mapped 1 → 2 → 3 → 1, then σ 0 instead maps 1 ← 2 ← 3 ← 1,
but is equal to σ on all other inputs.)
Since the permutations σ 0 and σ only differ in an odd cycle, by the definitions of the sign of permu-
tations, we have sgn(σ) = sgn(σ 0 ). It is not hard to see that fσ = −fσ0 due to the fact that M satisfies
M T = −M : We reversed an odd cycle, so that an odd number of signs are reversed. Thus we have
For the forward direction, if the formula is not equal to zero, then we have at least one σ with fσ 6= 0.
This means there is an even cycle cover of G, which in turn implies a perfect matching. Indeed, if we
pick every other edge in each even cycle, or just the single edge in the case of a cycle of length 2, the
result will be a perfect matching for G.
For the backward direction, if G has a perfect matching, then each node is connected by exactly one
edge in the matching. We define a permutation σ ∈ Sn by turning each edge into a cycle formed by two
edges, as shown below:
=⇒
6
By doing this, we convert a perfect matching into an even-cycle cover σ. Therefore:
n
Y
fσ = M [i, σ(i)]
i=1
Y
= M [i, j] · M [j, i], because all edges are part of a 2-cycle
(i,j) ∈ matching
Y
= −x2ij .
(i,j) ∈ matching
There is no other σ 0 ∈ Sn such that fσ and fσ0 use the same set of variables since σ uses all the copies of
P
every variable it uses in M . Therefore, σ∈Sn \On sgn(σ)fσ 6= 0, since the term corresponding to our σ
can’t get canceled out. This completes the proof.