You are on page 1of 39

Lecture 7: Property Testing in

Bounded-Degree Graphs

1
Review: Property Testing
Tester

?
𝑥 ∈ 0,1 𝑛
?
?

2
Review: Property Testing
Given 𝑥 ∈ 0,1 𝑛 and a property 𝑃 ⊆ 0,1 𝑛 , distinguish between:
• 𝑥 ∈ 𝑃,
• 𝑥 is 𝜖-far from 𝑃:
for all 𝑦 ∈ 𝑃 we have Δ 𝑥, 𝑦 ≥ 𝜖 ⋅ 𝑛.

3
Property Testing in Graphs: Models
• Bounded-degree graphs:
• deg 𝑣 ≤ 𝑑 for each 𝑣 ∈ 𝑉
• Stored as adjacency list
• Queries: “who is the 𝑖-th neighbor of 𝑣?”
• Treat 𝑑 ≥ 2 as constant
• Dense graphs:
• 𝐸 = Θ 𝑛2
• Stored as adjacency matrix
• Queries: “are 𝑖, 𝑗 neighbors?”
• General graphs
4
Which Graphs Have Bounded Degree?
• Peer-to-peer networks
• Road networks
•…

5
What Does “Far” Mean?
• Δ 𝐺1 , 𝐺2 : #edge differences

• 𝐺 is 𝜖-far from 𝑃: must change 𝜖 ⋅ 𝑑𝑘 edges to get 𝑃

6
What is a Property?
• 𝑃 ⊆ { bounded-degree graphs on 𝑘 vertices }

• Restrict to symmetric properties

7
Techniques
1. Local search:
• Select uniformly random 𝑣 ∈ 𝑉
• Query 𝑣’s entire 𝑟-neighborhood
• Examine it and decide
2. Random walk:
• Select uniformly random 𝑣 ∈ 𝑉
• Take random walk of length ℓ
• Examine it and decide

8
Algorithmic Idea #1
𝐺∉𝑃

Not having the property: 𝜖-far from having the property:

9
Algorithmic Idea #2
• Reduce to estimating some quantity
• Estimate by sampling

10
Today
Testers for:
1. Triangle-freeness
2. Connectivity
3. Cycle-freeness
4. Bipartiteness

11
Example 1: Triangle-Freeness
• 𝑃△ = { all triangle-free bounded-degree graphs on 𝑘 vertices }
• Tester: repeat
• Choose uniformly random 𝑣 ∈ 𝑉
• Query 𝑣’s 2-neighborhood
• Found triangle ⇒ reject
• Obvious: if 𝐺 ∈ 𝑃△ we accept
• Not obvious: if 𝐺 is 𝜖-far from 𝑃△ we reject?

12
“Far From Triangle-Free”
• Claim: 𝐺 is 𝜖-far from △-free ⇒ at least 𝜖 ⋅ 𝑘 vertices are in a triangle.
• Proof: suppose not…
1. Let 𝑈 ⊆ 𝑉 be the vertices that are in a triangle
2. Remove all edges adjacent to 𝑈 ⇒ △-free
3. At most 𝑈 ⋅ 𝑑 edges adjacent to 𝑈
⇒ 𝑈 ⋅𝑑 ≤𝜖⋅𝑘⋅𝑑

• Corollary: Pr 𝑣 ∈ 𝑈 ≥ 𝜖
𝑣∈𝑉

13
Example 2: Connectivity
• Idea: “far from connected” ≈ “lots of connected components”
• Formally:
If 𝐺 has 𝑚 connected components, then there is a graph 𝐺′ s.t.:
1. 𝐺′ is connected,
2. 𝐺′ has maximum degree 𝑑,
3. Δ 𝐺, 𝐺 ′ ≤ 2𝑚 − 1.
• Attempt #1: add path over connected components
𝑚 components ⇒ 𝑚 − 1 edges
• Fix: create “connection points”
14
Proof of Claim
• Component 𝐶 = 𝑉𝐶 , 𝐸𝐶 is saturated if σ𝑣∈𝑉𝐶 deg 𝑣 ≥ 𝑉𝐶 ⋅ 𝑑 − 1

V𝐶 = 5, 𝑑 = 3
V𝐶 = 6, 𝑑 = 5

• Claim: if 𝐶 is not saturated, ∃𝑣 ≠ 𝑣 ′ ∈ 𝑉𝐶 with deg 𝑣 , deg 𝑣 ′ < 𝑑


15
Proof of Claim
• Component 𝐶 = 𝑉𝐶 , 𝐸𝐶 is saturated if σ𝑣∈𝑉𝐶 deg 𝑣 ≥ 𝑉𝐶 ⋅ 𝑑 − 1
• Claim: if 𝐶 is not saturated, ∃𝑣, 𝑣 ′ ∈ 𝑉𝐶 with deg 𝑣 , deg 𝑣 ′ < 𝑑 :

෍ deg 𝑣 ≤ 𝑉𝐶 ⋅ 𝑑 − 2
𝑣∈𝑉𝐶
= 𝑉𝐶 − 2 ⋅ 𝑑 + 2 𝑑 − 1

16
Proof of Claim
• Component 𝐶 = 𝑉𝐶 , 𝐸𝐶 is saturated if σ𝑣∈𝑉𝐶 deg 𝑣 ≥ 𝑉𝐶 ⋅ 𝑑 − 1
• If 𝐶 is saturated:
• Construct spanning tree 𝑇 = 𝑉𝐶 , 𝐸𝑇 inside 𝐶
• Can remove some edge without touching 𝑇:

σ𝑣∈𝑉𝐶 deg 𝑣 𝑉𝐶 ⋅ 𝑑 − 1 𝑉𝐶 ⋅ 𝑑 − 𝑑 𝑉𝐶 − 1 ⋅ 𝑑
𝐸𝐶 = ≥ > =
2 2 2 2

17
Proof of Claim

#edges removed ≤ 𝑚 #edges added ≤ 𝑚 − 1

18
What to Do With the Claim?
If 𝐺 has 𝑚 connected components, then there is a graph 𝐺′ s.t.:
1. 𝐺′ is connected,
2. 𝐺′ has maximum degree 𝑑,
3. Δ 𝐺, 𝐺 ′ ≤ 2𝑚 − 1.

• 𝐺 is 𝜖-from connected ⇒ has ≥ 𝜖𝑑𝑘/2 components


• 𝐺 is connected ⇒ has 1 component

19
Checking for Lots of CCs
• Observation: if 𝐺 has lots of components, then 𝐺 has lots of small
components
4
• Say 𝐶 is “small” if 𝑉𝐶 ≤
𝜖𝑑

𝑘 𝜖𝑘𝑑
#components = #small + #large ≤ #small+ 4 = #small +
4
𝜖𝑑

20
Checking for Lots of CCs
• Observation: 𝐺 has lots of small components
𝜖𝑑𝑘 4
• At least components have size ≤
4 𝜖𝑑
𝜖𝑑
• Random vertex ∈ small component w.p. ≥
4

• How to tell if it’s a small component?


• #Queries?

21
Example 3: Cycle-Freeness
• If 𝐺 is connected, then 𝐺 is cycle-free ⇔ 𝐸 ≤ 𝑘 − 1
• What if 𝐺 is not connected?
• Claim: if 𝐺 has 𝑚 CCs, 𝐺 is cycle-free ⇔ 𝐸 ≤ 𝑘 − 𝑚
• Idea:
1. Estimate 𝐸 For connectivity:
2. Estimate 𝑚 =#CCs 𝐺 is 𝜖-from connected ⇒ has ≥ 𝜖𝑑𝑘/2 components
𝐺 is connected ⇒ has 1 component
3. Compare (?)

22
Estimating 𝐸
1
• Randomly query Θ pairs 𝑣, 𝑖 ∈ 𝑉 × 𝑑
𝜖2
𝐸
• Pr[𝑄𝑢𝑒𝑟𝑦 𝑣, 𝑖 ≠ “empty”] =
𝑘𝑑
• Let 𝑒Ƹ = (fraction of queries that return “empty”) ⋅ 𝑘𝑑
𝐸
• E 𝑒Ƹ = ⋅ 𝑘𝑑 = 𝐸
𝑘𝑑
1 𝜖
• Average Θ trials ⇒ 𝑒Ƹ ∈ 1 ± 𝐸 w.h.p.
𝜖2 10

23
Estimating #CCs
• Idea: approximate “average CC size”
σ𝐶∈𝐶𝐶𝑠 𝐶
• Average CC size =
#𝐶𝐶𝑠
𝑘
• #𝐶𝐶𝑠 = Average CC size

• How?
• For 𝑖 = 1, … , 𝑡,
• Sample random node 𝑣𝑖 ∈ 𝑉
• 𝑋𝑖 ← 𝑘/ 𝐶 𝑣𝑖 ???

• 𝐸 𝑋𝑖 =

24
Estimating Component Size
8
• Small components, 𝐶 ≤ 𝑆: can compute their size Threshold 𝑆 =
𝑑𝜖
⇒ good estimate for 𝑚𝑆
𝑚𝑆 : #CCs of size ≤ 𝑆
• Large components, 𝐶 > 𝑆: ignore them, 𝑚𝐿 ≤ 𝑘/𝑆 𝑚𝐿 : #CCs of size > 𝑆
• Experiment:
• Choose uniformly random 𝑣𝑖 ∈ 𝑉
• Explore 𝑣’s component 𝐶 𝑣𝑖 , up to 𝑆 = 8/(𝑑𝜖) vertices
0, 𝑖𝑓 𝐶 𝑣 > 𝑆
• 𝑋𝑖 = ቐ 𝑘
, 𝑖𝑓 𝐶 𝑣 ≤ 𝑆
𝐶 𝑣
1 𝜖𝑑
• Average Θ trials ⇒ 𝑚
ෝ𝑆 ∈ 1 ± 𝑚𝑆 w.h.p.
𝜖𝑑 2 10
25
Comparing the Estimates
𝜖
• 𝑒Ƹ ∈ 1 ± 𝐸 w.h.p.
10
𝜖𝑑
•𝑚
ෝ𝑆 ∈ 1 ± 𝑚𝑆 w.h.p.
10
• Want to know: 𝐸 ≤ 𝑘 − 𝑚 ?

• Recall: 𝐸 = 2𝑑𝑘 and 𝑚𝑆 ≤ 𝑘


𝑘 𝜖𝑑𝑘
• 𝑚 = 𝑚𝑆 + 𝑚𝐿 where 𝑚𝐿 ≤ =
𝑆 8

26
Putting Everything Together
• Assume: If 𝐺 is cycle-free:
𝜖 1
• 𝑒Ƹ ∈ 1 ± 20 𝐸 = 𝐸 ± 10 𝜖𝑑𝑘
𝜖𝑑 1
• 𝑚
ෝ𝑆 ∈ 1 ± 𝑚𝑆 = 𝑚𝑆 ± 𝜖𝑑𝑘
10 10
𝑘 1
• 𝑚𝐿 ≤ = 𝜖𝑑𝑘
𝑆 8
• Want to know: 𝐸 ≤ 𝑘 − 𝑚 ?
• If 𝑒Ƹ ≥ 𝑘 − 𝑚
ෝ 𝑆 + 𝜖𝑑𝑘/4 ⇒ reject
• Else ⇒ accept

27
Putting Everything Together
• Assume: If 𝐺 is 𝜖-far from cycle-free:
𝜖 1
• 𝑒Ƹ ∈ 1 ± 20 𝐸 = 𝐸 ± 10 𝜖𝑑𝑘
𝜖𝑑 1
• 𝑚
ෝ𝑆 ∈ 1 ± 𝑚𝑆 = 𝑚𝑆 ± 𝜖𝑑𝑘
10 10
𝑘 1
• 𝑚𝐿 ≤ = 𝜖𝑑𝑘
𝑆 8
• Want to know: 𝐸 ≤ 𝑘 − 𝑚 ?
• If 𝑒Ƹ ≥ 𝑘 − 𝑚
ෝ 𝑆 + 𝜖𝑑𝑘/4 ⇒ reject
• Else ⇒ accept

28
Example 4: Testing Bipartiteness

29
Testing Bipartiteness
• 𝐺 is bipartite ⇔ has no odd closed walks
• Claim (without proof):
𝐺 is 𝜖-far from bipartite ⇒ has many odd cycles
of length 𝑂 log 𝑘
• How to check?

30
Random Walks
• Random walk: 𝜋 = 𝑣1 , … , 𝑣𝐿 , where
1
Pr 𝑣𝑖+1 = 𝑢 𝑣𝑖 = for each 𝑢 ∈ 𝑁 𝑣𝑖 .
deg 𝑣𝑖

• Lazy random walk:


1
Pr 𝑣𝑖+1 = 𝑢 𝑣𝑖 = for each 𝑢 ∈ 𝑁 𝑣𝑖
2𝑑
deg 𝑣𝑖
Pr 𝑣𝑖+1 = 𝑣𝑖 = 1 −
2𝑑
Fix start point 𝑠 ∈ 𝑉
• Parity of lazy 𝜋: #non-lazy steps even/odd?
𝑝 𝑣 = Pr[𝜋 ends at 𝑣]

31
Rapidly-Mixing Graphs
• General graphs can have “wild” 𝑝 𝑣

Clique Clique

• We assume: 𝑝 𝑣 ≈ 1/𝑘 for all 𝑣 ∈ 𝑉 Random walk of length 𝐿 ≈


random walk of length 𝐿 − 1
For each 𝑣 ∈ 𝑉:
1 2
≤ Pr 𝑣𝐿 = 𝑣 ≤
2𝑘 𝑣1 ,…,𝑣𝐿 ∼𝑅𝑊𝐿 𝑘
32
The Tester
• Select random 𝑠 ∈ 𝑉
• 𝑅0 ← ∅, 𝑅1 ← ∅

• Repeat 𝑚 = Θ 𝑘/poly 𝜖 times:
log 𝑘
• 𝜋 ← lazy random walk of length 𝐿 = poly from 𝑣
𝜖
• If 𝜋 has even parity: add endpoint to 𝑅0
• If 𝜋 has odd parity: add endpoint to 𝑅1
• Reject iff 𝑅0 ∩ 𝑅1 ≠ ∅

33
Analysis
• Let 𝑝0 𝑣 = Pr[ 𝑣𝐿 = 𝑣 and 𝜋 has even parity ]
𝑝1 𝑣 = Pr[ 𝑣𝐿 = 𝑣 and 𝜋 has odd parity ]
1 2
𝑝 𝑣 = 𝑝0 𝑣 + 𝑝1 𝑣 ∈ ,
2𝑘 𝑘

• Pr 𝑣 ∈ 𝑅0 ∩ 𝑅1 grows with 𝑝0 𝑣 ⋅ 𝑝1 𝑣
• Claim:
1. If σ𝑣 𝑝0 𝑣 𝑝1 𝑣 is small: 𝐺 is 𝜖-close to bipartite
2. If σ𝑣 𝑝0 𝑣 𝑝1 𝑣 is large: good probability to reject
𝐺 is 𝜖-far from bipartite ⇒ good probability to reject
34
Claim 1: Small Sum ⇒ Close to Bipartite
• Suppose σ𝑣 𝑝0 𝑣 𝑝1 𝑣 ≤ 0.01𝜖/𝑘
• Goal: find partition 𝑉1 , 𝑉2 with few “violating edges”

• Example: σ𝑣 𝑝0 𝑣 𝑝1 𝑣 = 0

𝑠 𝑢1 𝑢2 𝑢3
𝑝0 1 1 0 0
𝑝1 0 0 1 1

35
Claim 1: Small Sum ⇒ Close to Bipartite
• Suppose σ𝑣 𝑝0 𝑣 𝑝1 𝑣 ≤ 0.01𝜖/𝑘
• Let 𝑉1 = 𝑣: 𝑝0 𝑣 < 𝑝1 𝑣 1 2
𝑝 𝑣 = 𝑝0 𝑣 + 𝑝1 𝑣 ∈ ,
𝑉2 = 𝑣: 𝑝0 𝑣 ≥ 𝑝1 𝑣 2𝑘 𝑘
• Then #edges inside 𝑉1 or 𝑉2 ≤ 𝜖𝑑𝑘:

𝑠
𝑝0 𝑣 not much
smaller than 𝑝1 𝑣

𝑉1 𝑉2

36
Claim 1: Small Sum ⇒ Close to Bipartite
𝑢
𝑠
• Let 𝑢, 𝑣 ∈ 𝐸 s.t. 𝑢, 𝑣 ∈ 𝑉1 𝑣
𝑝1 𝑣 ≥ 1/4𝑘
• Ways to reach 𝑣:
1. Take odd-parity 𝐿-step walk to 𝑣 𝑉1 𝑉2
2. Take odd-parity 𝐿 − 1 -step walk to 𝑢, then edge 𝑢, 𝑣
• Let 𝑝1′ 𝑢 = Pr[ 𝐿 − 1 -step walk with odd parity ends at 𝑢 ]
1
• 𝑝1′ 𝑢 ∈ 1± 𝑝1 𝑢 σ𝑣 𝑝0 𝑣 𝑝1 𝑣 ≤ 0.01𝜖/𝑘
10
1 1 1 1
• Then 𝑝0 𝑣 ≥ 𝑝1′ 𝑢 ⋅ ≥ 𝑝1 𝑢 ⋅ ≥ ⋅
2𝑑 3𝑑 4𝑘 3𝑑

𝑝1 𝑢 ≥ 1/4𝑘
37
Claim 2: Large Sum ⇒ Probably Reject
• Assume σ𝑣 𝑝0 𝑣 𝑝1 𝑣 > 0.01𝜖/𝑘
• Define indicator 𝐴𝑖,𝑗 :
• The 𝑖-th random walk has even parity, Bound Pr σ𝑖,𝑗≤𝑚 𝐴𝑖,𝑗 = 0
• The 𝑗-th random walk has odd parity,
• Both end at the same vertex.
• σ𝑖,𝑗≤𝑚 𝐴𝑖,𝑗 ≥ 1 ⇒ reject! 𝑘

𝑚=Θ
• Pr 𝐴𝑖,𝑗 = 1 = σ𝑣∈𝑉 𝑝0 𝑣 𝑝1 𝑣 poly 𝜖
2 0.01𝜖
• E σ𝑖,𝑗≤𝑚 𝐴𝑖,𝑗 = Ω 𝑚 ⋅
𝑘

38
Today
Testers for:
1. Triangle-freeness
2. Connectivity
3. Cycle-freeness
4. Bipartiteness

39

You might also like