93
Shanghai Jiao Tong University Chihao Zhang Advanced Algorithms (I) March 2nd, 2020

Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 ([email protected])

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Shanghai Jiao Tong University

Chihao Zhang

Advanced Algorithms (I)

March 2nd, 2020

Page 2: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Information

Every Monday, 10:00 am - 11:40 am

Zoom @ 123363659

Instructor: 张驰豪 ([email protected])

TA: 杨凤麟 ([email protected])

Office Hour: via Canvas or WeChat Group

Page 3: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

References

Probability and Computing Randomized Algorithms The Probabilistic Method

M. Mitzenmacher & E. Upfal R. Motwani & P. Raghavan N. Alon & J. Spencer

Page 4: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Polynomial Identity Testing

Page 5: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Polynomial Identity TestingGiven two polynomials

and F(x) =d

∏i=1

(x − ai) G(x) =d

∑i=0

bixi

Page 6: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Polynomial Identity TestingGiven two polynomials

and F(x) =d

∏i=1

(x − ai) G(x) =d

∑i=0

bixi

Is F(x) ≡ G(x)?

Page 7: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Polynomial Identity TestingGiven two polynomials

and F(x) =d

∏i=1

(x − ai) G(x) =d

∑i=0

bixi

Is F(x) ≡ G(x)?

Example. F(x) = (x − 1)(x − 2)(x + 3); G(x) = x3 − 7x + 6

Page 8: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)
Page 9: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

One can expand and compare the coefficients…F(x)

Page 10: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

One can expand and compare the coefficients…F(x)

It takes arithmetic operations.O(d2)

Page 11: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

One can expand and compare the coefficients…F(x)

It takes arithmetic operations.O(d2)

Can be improved to using FFT.O(d log d)

Page 12: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

One can expand and compare the coefficients…F(x)

It takes arithmetic operations.O(d2)

Can be improved to using FFT.O(d log d)

If random coins are allowed…

Page 13: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

One can expand and compare the coefficients…F(x)

It takes arithmetic operations.O(d2)

Can be improved to using FFT.O(d log d)

If random coins are allowed…

• The problem can be solved much faster

Page 14: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

One can expand and compare the coefficients…F(x)

It takes arithmetic operations.O(d2)

Can be improved to using FFT.O(d log d)

If random coins are allowed…

• The problem can be solved much faster

• at the cost of making error.

Page 15: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)
Page 16: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Choosing a uniform number s ∈ {1,2,…,100d}

Page 17: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Choosing a uniform number s ∈ {1,2,…,100d}

Test whether F(s) = G(s)

Page 18: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Choosing a uniform number s ∈ {1,2,…,100d}

Test whether F(s) = G(s)

• If , then it always holds that F(x) ≡ G(x) F(s) = G(s)

Page 19: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Choosing a uniform number s ∈ {1,2,…,100d}

Test whether F(s) = G(s)

• If , then it always holds that F(x) ≡ G(x) F(s) = G(s)

• If , how likely is that ?F(x) ≢ G(x) F(s) ≠ G(s)

Page 20: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Choosing a uniform number s ∈ {1,2,…,100d}

Test whether F(s) = G(s)

• If , then it always holds that F(x) ≡ G(x) F(s) = G(s)

• If , how likely is that ?F(x) ≢ G(x) F(s) ≠ G(s)

Theorem. (Fundamental Theorem of Algebra)

A polynomial of degree has at most roots in d d ℂ

Page 21: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)
Page 22: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Our algorithm outputs wrong answer only when

Page 23: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Our algorithm outputs wrong answer only when

• ; andF(x) ≢ G(x)

Page 24: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Our algorithm outputs wrong answer only when

• ; andF(x) ≢ G(x)

• is a root of s F(x) − G(x)

Page 25: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Our algorithm outputs wrong answer only when

• ; andF(x) ≢ G(x)

• is a root of s F(x) − G(x)

This happens with probability at most .1

100

Page 26: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Our algorithm outputs wrong answer only when

• ; andF(x) ≢ G(x)

• is a root of s F(x) − G(x)

This happens with probability at most .1

100

It only costs operations to compute and .O(d) F(s) G(s)

Page 27: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Our algorithm outputs wrong answer only when

• ; andF(x) ≢ G(x)

• is a root of s F(x) − G(x)

This happens with probability at most .1

100

It only costs operations to compute and .O(d) F(s) G(s)

One can repeat the algorithm times: t

• error reduces to ;100−t

• cost increases to .O(td)

Page 28: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Multi-variable Polynomials

Page 29: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Multi-variable Polynomials

The idea applies to a more general setting.

Page 30: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Multi-variable Polynomials

The idea applies to a more general setting.

Let for some field ,F, G ∈ 𝔽(x1, …, xn) 𝔽

Page 31: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Multi-variable Polynomials

The idea applies to a more general setting.

Let for some field ,F, G ∈ 𝔽(x1, …, xn) 𝔽

Is F(x1, …, xn) ≡ G(x1, …, xn)?

Page 32: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Theorem. (Schwartz-Zippel Theorem)

Let be a non-zero multivariate polynomial of degree at most . For any set , it

holds that

Q ∈ 𝔽[x1, …, xn]d U ⊆ 𝔽

Prr1,…,rn∈RU

[Q(r1, …, rn) = 0] ≤d

|U |

Page 33: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Proof of Schwartz-Zippel

Page 34: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Proof of Schwartz-Zippel

Induction on , case is Fundamental Theorem of Algebra.

n n = 1

Page 35: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Proof of Schwartz-Zippel

Induction on , case is Fundamental Theorem of Algebra.

n n = 1

Assuming it holds for smaller …n

Page 36: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Proof of Schwartz-Zippel

Induction on , case is Fundamental Theorem of Algebra.

n n = 1

Assuming it holds for smaller …n

Q(x1, …, xn) =k

∑i=0

xi1 ⋅ Qi(x2, …, xn)

Page 37: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Proof of Schwartz-Zippel

Induction on , case is Fundamental Theorem of Algebra.

n n = 1

Assuming it holds for smaller …n

Q(x1, …, xn) =k

∑i=0

xi1 ⋅ Qi(x2, …, xn)

Pr [Q = 0] ≤ Pr [Qk = 0] + Pr [Q = 0 |Qk ≠ 0] ≤d − k|U |

+k

|U |

Page 38: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)
Page 39: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Our randomized algorithm generalizes to the multi-variable setting by Schwartz-Zippel theorem.

Page 40: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Our randomized algorithm generalizes to the multi-variable setting by Schwartz-Zippel theorem.

If the polynomials are given in product form, one scan of and is sufficient to evaluate them.F G

Page 41: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Our randomized algorithm generalizes to the multi-variable setting by Schwartz-Zippel theorem.

If the polynomials are given in product form, one scan of and is sufficient to evaluate them.F G

Linear time algorithm with at most error!1 %

Page 42: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Our randomized algorithm generalizes to the multi-variable setting by Schwartz-Zippel theorem.

If the polynomials are given in product form, one scan of and is sufficient to evaluate them.F G

Linear time algorithm with at most error!1 %

It is a wide open problem in the complexity theory that whether this can be done in deterministic polynomial time.

Page 43: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Some Complexity Theory

Page 44: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Some Complexity Theory

Problems solvable in deterministic polynomial-time: P

Page 45: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Some Complexity Theory

Problems solvable in deterministic polynomial-time: P

Problems solvable in randomized polynomial-time: BPP

Page 46: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Some Complexity Theory

Problems solvable in deterministic polynomial-time: P

Problems solvable in randomized polynomial-time: BPP

Is ?BPP = P

Page 47: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Min-Cut in a Graph

Page 48: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Min-Cut in a GraphA cut in a graph is a set of edges whose removal disconnects .

G = (V, E) C ⊆ EG

Page 49: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Min-Cut in a GraphA cut in a graph is a set of edges whose removal disconnects .

G = (V, E) C ⊆ EG

How to find the minimum cut?

Page 50: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Min-Cut in a GraphA cut in a graph is a set of edges whose removal disconnects .

G = (V, E) C ⊆ EG

How to find the minimum cut?

It can be solved using max-flow techniques

Page 51: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Min-Cut in a GraphA cut in a graph is a set of edges whose removal disconnects .

G = (V, E) C ⊆ EG

How to find the minimum cut?

It can be solved using max-flow techniques

With the fastest max-flow algorithm, it takes time.

O(n × mn)

Page 52: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Karger’s Min-Cut Algorithm

Page 53: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Karger’s Min-Cut Algorithm

David Karger

Page 54: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Karger’s Min-Cut Algorithm

David Karger

Using random bits, Karger found a much simpler algorithm

Page 55: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Karger’s Min-Cut Algorithm

David Karger

Using random bits, Karger found a much simpler algorithm

The only operation required is edge contraction

Page 56: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Edge Contraction

Page 57: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Edge Contraction

1

2

3

Page 58: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Edge Contraction

1

2

3

1

2

3

Page 59: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Edge Contraction

1

2

3

1

2

3

Page 60: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Edge Contraction

1

2

3

1

2

3 1/2 3

Page 61: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Edge Contraction

1

2

3

1

2

3 1/2 3

Page 62: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Edge Contraction

1

2

3

1

2

3 1/2 3

• no self-loop

Page 63: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Edge Contraction

1

2

3

1

2

3 1/2 3

• parallel edges may exist

• no self-loop

Page 64: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

The Algorithm

Page 65: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

The Algorithm

Karger’s Min-cut Algorithm

1. Randomly choose an edge and contract it until only two vertices remains.

2. Output remaining edges.

Page 66: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Analysis

Page 67: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

AnalysisThe algorithm contracts pair of vertices in total.n − 2

Page 68: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

AnalysisThe algorithm contracts pair of vertices in total.n − 2

Fix an minimum cut , we bound the probability that it survives.

C

Page 69: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

AnalysisThe algorithm contracts pair of vertices in total.n − 2

Fix an minimum cut , we bound the probability that it survives.

C

Assume the removal of separates and .

C S ⊆ VS̄ = V∖S

Page 70: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

AnalysisThe algorithm contracts pair of vertices in total.n − 2

Fix an minimum cut , we bound the probability that it survives.

C

Assume the removal of separates and .

C S ⊆ VS̄ = V∖S

All contractions happen within or .S S̄

Page 71: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)
Page 72: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

For , let be the event that “ -th contraction avoids ”

i = 1,…, n − 2 Ai iC

Page 73: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

For , let be the event that “ -th contraction avoids ”

i = 1,…, n − 2 Ai iC

We need to bound

Page 74: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

For , let be the event that “ -th contraction avoids ”

i = 1,…, n − 2 Ai iC

We need to bound

Pr [n−2

⋂i=1

Ai] =n−2

∏i=1

Pr Ai

i−1

⋂j=1

Aj

Page 75: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

For , let be the event that “ -th contraction avoids ”

i = 1,…, n − 2 Ai iC

We need to bound

Pr [n−2

⋂i=1

Ai] =n−2

∏i=1

Pr Ai

i−1

⋂j=1

Aj

We assume |C | = k

Page 76: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)
Page 77: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

In -th contraction,i

Page 78: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

In -th contraction,i

• the graph contains vertices;

• each vertex is of degree at least .

n − i + 1

k

Page 79: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

In -th contraction,i

• the graph contains vertices;

• each vertex is of degree at least .

n − i + 1

k

Therefore, conditional on that still survives,C

Page 80: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

In -th contraction,i

• the graph contains vertices;

• each vertex is of degree at least .

n − i + 1

k

Therefore, conditional on that still survives,C

Pr Ai

i−1

⋂j=1

Aj ≥ 1 −2k

k(n − i + 1)=

n − i − 1n − i + 1

Page 81: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)
Page 82: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Therefore

Page 83: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Therefore

Pr [n−2

⋂i=1

Ai] =n−2

∏i=1

Pr Ai

i−1

⋂j=1

Aj

≥n−2

∏i=1

n − i − 1n − i + 1

=n − 2

n⋅

n − 3n − 1

⋯13

=2

n(n − 1)

Page 84: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)
Page 85: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

So if we repeat the algorithm times, the minimum cut survives with probability at least

50n2

Page 86: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

So if we repeat the algorithm times, the minimum cut survives with probability at least

50n2

1 − (1 −2

n(n − 1) )50n2

≥ 1 − e−100

Page 87: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

So if we repeat the algorithm times, the minimum cut survives with probability at least

50n2

1 − (1 −2

n(n − 1) )50n2

≥ 1 − e−100

How about the time cost?

Page 88: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

So if we repeat the algorithm times, the minimum cut survives with probability at least

50n2

1 − (1 −2

n(n − 1) )50n2

≥ 1 − e−100

How about the time cost?

If we store the graph in a adjacency matrix, one needs to contract an edge…O(n)

Page 89: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Karger-Stein’s Trick

Page 90: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Karger-Stein’s Trick

Recall Pr [n−2

⋂i=1

Ai] =n − 2

n⋅

n − 3n − 1

⋯13

Page 91: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Karger-Stein’s Trick

Recall Pr [n−2

⋂i=1

Ai] =n − 2

n⋅

n − 3n − 1

⋯13

The more we contracts, the easier gets hitC

Page 92: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Karger-Stein’s Trick

Recall Pr [n−2

⋂i=1

Ai] =n − 2

n⋅

n − 3n − 1

⋯13

The more we contracts, the easier gets hitC

Idea: Make a copy before it becomes too bad!

Page 93: Advanced Algorithms (I)chihaozhang.com/teaching/AA2020spring/slides/lec1-slides.pdfInformation Every Monday, 10:00 am - 11:40 am Zoom @ 123363659 Instructor: 张驰豪 (chihao@sjtu.edu.cn)

Karger-Stein’s Trick

Recall Pr [n−2

⋂i=1

Ai] =n − 2

n⋅

n − 3n − 1

⋯13

The more we contracts, the easier gets hitC

Idea: Make a copy before it becomes too bad!

The success probability can be improved to Ω ( 1log n )