27
(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering National Chi Nan University Chapter 9 Connectivity § 9.8 More (變異, 變化)

Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan

1

Computer Science and Information Engineering

National Chi Nan University

Chapter 9

Connectivity

§ 9.8 More (變異, 變化)

Page 2: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan2

§ 9.8 More

I. With lower bound

• Def:

A flow f: E R in a network N(V, E) with lower bound b(e) 0,

upper bound c(e) ( b(e)) means:

(i) b(e) f(e) c(e), e E

(ii) e(V,v) f(e) = e(v,V) f(e), v V {s, t}

value(f) = e(s,V) f(e) e(V,s) f(e).

a cut in N (S, SC) = {xy: x S, y SC}, where s S and t SC.

Page 3: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan3

§ 9.8 More

• Def:

value(S, SC) = e(S,SC) c(e) e(SC,S) b(e).

An edge e = xy in a network N with flow f is called useful

f(e) < c(e), if xy E(N)

f(e) > b(e), if yx E(N).

Page 4: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan4

§ 9.8 More

• Problem: Solve the max. flow in a network N with s, t, b, c.

Sol.

reduce to N* with s*, t*, Cap*: where

V(N*) = V(N) {s*, t*}

E(N*) = E(N) {s*v, vt*: v V(N)} {st, ts}

Cap*(e) = c(e) b(e), if e E(N)

xvE(N) b(xv), if e = s*v

vyE(N) b(vy), if e = vt*

, if e = st or ts

Page 5: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan5

2 301

1

2 03

§ 9.8 More

• Ex:

s t

a

b

(1, 3)

(2, 5)

(2, 4)

(1, 6)

N

t*

s*

s t

a

b

2 2

3 5

Page 6: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan6

• Theorem: N has a flow f with lower bound and upper bound

conditions N* has a flow f* of value = vV(N) Cap*(s*v)

= vV(N) Cap*(vt*) = eE(N) b(e).

Note: such f* will be f*(s*v) = Cap*(s*v)

f*(vt*) = Cap*(vt*) v V(N)

Proof. (1/5)

() given f, then define f* by:

f(e) b(e), if e E(N)

Cap*(e), if e = s*v

f*(e) = Cap*(e), if e = vt*

vV(N) f(vt) vV(N)f(tv), if e = ts

0, if e = st

(Need check!! (略))

§ 9.8 More

Page 7: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan7

2 2

2 2

5 5

(1, 3) (1, 3)

§ 9.8 More

• Ex:

s t

a

b

(1, 3)

(2, 5)

(2, 4)

(1, 6)

d

2, 23, 31, 1

1, 11, 1

3, 3 5, 4

1, 1

2, 1

2, 1

, 0

, 5

2, 2 1, 13, 3

2, 1 2, 0

1, 1

s t

a

b

t*

s*

d

Page 8: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan8

§ 9.8 More

• Theorem: N has a flow f with lower bound and upper bound

conditions N* has a flow f* of value = vV(N) Cap*(s*v)

= vV(N) Cap*(vt*) = eE(N) b(e).

Note: such f* will be f*(s*v) = Cap*(s*v)

f*(vt*) = Cap*(vt*) v V(N)

Proof. (2/5)

() given f*, define f by:

f(e) = f*(e) + b(e), e E(N).

check:

(i) 0 f*(e) Cap*(e) = c(e) b(e), e E(N)

b(e) f*(e) + b(e) c(e), e E(N)

b(e) f(e) c(e), e E(N)

Page 9: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan9

§ 9.8 More

• Ex:

2 2

2 2

s t

a

b

(1, 3)

(2, 5)

(2, 4)

(1, 6)

2, 23, 30, 0

1, 11, 1

3, 05, 1

, 4

, 0

2, 2 0, 03, 3

2, 1 2, 0

s t

a

b

t*

s*

Page 10: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan10

§ 9.8 More

• Theorem: N has a flow f with lower bound and upper bound

conditions N* has a flow f* of value = vV(N) Cap*(s*v)

= vV(N) Cap*(vt*) = eE(N) b(e).

Note: such f* will be f*(s*v) = Cap*(s*v)

f*(vt*) = Cap*(vt*) v V(N)

Proof. (3/5)

() given f*, define f by:

f(e) = f*(e) + b(e), e E(N).

check:

(ii) ∵ value(f*) = vV(N) Cap*(s*v)

f*(s*v) = Cap*(s*v), v V(N)

f*(vt*) = Cap*(vt*), v V(N)

Page 11: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan11

§ 9.8 More

• Theorem: N has a flow f with lower bound and upper bound

conditions N* has a flow f* of value = vV(N) Cap*(s*v)

= vV(N) Cap*(vt*) = eE(N) b(e).

Note: such f* will be f*(s*v) = Cap*(s*v)

f*(vt*) = Cap*(vt*) v V(N)

Proof. (4/5)

(ii) v V(N) {s, t}:

xvE(N) f(xv) = xvE(N) (f*(xv) + b(xv))

= xvE(N) f*(xv) + xvE(N) b(xv)

= xvE(N) f*(xv) + Cap*(s*v)

= xvE(N) f*(xv) + f*(s*v)

= xvE(N*) f*(xv).

Page 12: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan12

§ 9.8 More

• Theorem: N has a flow f with lower bound and upper bound

conditions N* has a flow f* of value = vV(N) Cap*(s*v)

= vV(N) Cap*(vt*) = eE(N) b(e).

Note: such f* will be f*(s*v) = Cap*(s*v)

f*(vt*) = Cap*(vt*) v V(N)

Proof. (5/5)

(ii) v V(N) {s, t}:

vyE(N) f(vy) = vyE(N) f*(vy) + vyE(N) b(vy)

= vyE(N) f*(vy) + Cap*(vt*)

= vyE(N) f*(vy) + f*(vt*)

= vyE(N*) f*(vy).

∵ In N*, xvE(N*) f*(xv) = vyE(N*) f*(vy) (∵ f* is a a flow)

xvE(N) f(xv) = vyE(N) f(vy).

Page 13: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan13

§ 9.8 More

II. Vertex with bound

• Def: A flow f: E R in a network N(V, E) with

c(e) 0, e E; c(v) 0, v V means:

(i) 0 f(e) c(e), e E

(ii) e(V,v) f(e) = e(v,V) f(e) c(v), v V {s, t}

Page 14: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan14

§ 9.8 More

• Problem: Solve the max. flow in a network N with bound c, e, v.

Sol.

Reduce to N* with Cap*: where

V(N*) = V(N) {v’: v V(N) {s, t}};

E(N*) = E1 E2 E3 E4 with

E1 = {sv: sv E(N)},

E2 = {v’t: vt E(N)},

E3 = {vv’: v V(N) {s, t}},

E4 = {v1’v2: v1v2 E(N) and {v1, v2} {s, t} = };

Cap*(e) = c(e), if e E1 E2 E4

c(v), if e E3

Page 15: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan15

• Ex:

N: N*:

• Note: 如欲將 N* 還原回 N: 則令 c(v) = 即可!

(用 II. 解一般 Network 問題)

§ 9.8 More

3

1

1

9

4

5

2s t

a

b

3

1

4

5

s t

a

b

a’

b’

1

9

2

Page 16: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan16

§ 9.8 More

III. Zero-One Network

• Def: A 0-1 network is a network G = (V, E) with s, t

and Cap(e) = 1, e E.

• Note: For a given flow f on a 0-1 network G:

An edge xy is called useful iff f(e) = 0, if xy E(G)

f(e) = 1, if yx E(G).

• Compare: Dinic Algorithm: O(|V|2|E|) = O(|V| |V| |E|)

MPM: O(|V|3)次 G* 次 DFS 每個

DFS

Page 17: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan17

§ 9.8 More

• Def: A network G = (V, E) is of

type 0 if Cap(e) = 1, e

type 1 if Cap(e) = 1, e (not exist parallel edges)

type 2 if Cap(e) = 1, e ( v V {s, t},

either |(V, v)| = 1 or |(v, V)| = 1.)

Page 18: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan18

§ 9.8 More

• Lemma 1: M* = Mf value(f),

where M* = max. value of a flow in G* (layered network of G)

Mf = max. value of a flow in G (在一定要用 f 之下)

f: a flow of G

Proof.

Let (S, SC) be a cut of G*, and s S, t SC:

Cap*(S, SC) = e(S,SC)G* Cap*(e)

= e(S,SC)G(1 f(e)) + e(SC,S)G

(f(e)) Cap(e)

= e(S,SC)GCap(e) [e(S,SC)G

f(e) e(SC,S)Gf(e)]

= Cap(S, SC) value(f)

Take min. over all cuts to get M* = Mf value(f).

(對某個在 G, 不在 G*

的邊, 其 Cap*(e)之值必為 0 沒有差)

Page 19: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan19

• Lemma 2: Let N = (V, E) be a 0-1 network of type 0 (1 or 2, resp.).

If we start with the zero flow, then the length of the layered

network is at most |E| / M (2|V| / √M or (|V| 2) / M + 1, resp.).

Proof. (1/3)

Note: E* = i=1r Ei, |Ei| |M|, i (∵ Ei is a cut with Cap = |Ei|)

type 0:

∵M = M* |Ei|, 1 i r

rM i=1r |Ei| = |E*| |E|

r |E| / M.

§ 9.8 More

E2E1 Erts V1 V2 Vr1V0 = = Vr

Page 20: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan20

• Lemma 2: Let N = (V, E) be a 0-1 network of type 0 (1 or 2, resp.).

If we start with the zero flow, then the length of the layered

network is at most |E| / M (2|V| / √M or (|V| 2) / M + 1, resp.).

Proof. (2/3)

type 1:

M = M* |Ei| |Vi1||Vi|, 1 i r

√M |Vi1| or √M |Vi|, 1 i r

√M |Vi1| + |Vi|, 1 i r

r√M |V0| + 2|V1| + 2|V2| + … + 2|Vr1| + |Vr|

2|V| 2

r (2|V| 2) / √M < 2|V| / √M.

§ 9.8 More

Page 21: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan21

• Lemma 2: Let N = (V, E) be a 0-1 network of type 0 (1 or 2, resp.).

If we start with the zero flow, then the length of the layered

network is at most |E| / M (2|V| / √M or (|V| 2) / M + 1, resp.).

Proof. (3/3)

type 2:

∵ Ap = 1, s-t paths Pi and type 2,

M internally disjoint s-t paths Pi

and |E(Pi)| = r, i =1, 2, …, M

|V| 2 + i=1M (|E(Pi)| 1)

= 2 + M (r 1)

(|V| 2) / M r 1

r (|V| 2) / M + 1.

§ 9.8 More

P1

P2

PM

s t

Page 22: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan22

§ 9.8 More

• Thm: The time complexity of Dinic’s algorithm is O(i|E|) for

type i network, where i = |E|1/2 if i = 0

|V|2/3 if i = 1

|V|1/2 if i = 2

Proof. (1/6)

① Maximum flow 花 O(|E|) 時間

(∵ Cap(e) = 1 用 DFS 可以找到)

② 估計 # iterations:

Case 1: M i # iterations i

Case 2: M > i:

Consider the phase under which the flow reach M i

Page 23: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan23

• Thm: The time complexity of Dinic’s algorithm is O(i|E|) for

type i network, where i = |E|1/2 if i = 0

|V|2/3 if i = 1

|V|1/2 if i = 2

Proof. (2/6)

② Case 2: M > i:

Consider the phase under which the flow reach M i

value(f) = 0

value(f) < M i: 此時 N* 的長度為 r, 其 max. value 為 M*

value(f) M i

value(f) = M

§ 9.8 More

# iteration r (by § 9.5 Lemma 1)

# iteration i (∵ 每次至少加1)

Page 24: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan24

• Thm: The time complexity of Dinic’s algorithm is O(i|E|) for

type i network, where i = |E|1/2 if i = 0

|V|2/3 if i = 1

|V|1/2 if i = 2

Proof. (3/6)

② Case 2: M > i:

Let f is the flow just before that.

value(f) < M i

此時 N* 中, 長度 r i = |E| / M* if i = 0

2|V| / √M* if i = 1

((|V| 2) / M*) + 1 if i = 2

where M* = M value(f) > i.

§ 9.8 More

Page 25: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan25

• Thm: The time complexity of Dinic’s algorithm is O(i|E|) for

type i network, where i = |E|1/2 if i = 0

|V|2/3 if i = 1

|V|1/2 if i = 2

Proof. (4/6)

② Case 2: M > i:

Total # of iteration i + r (by § 9.5 Lemma 1)

i + i

(by Claim 1) i + cii for some constant ci

= O(i ).

§ 9.8 More

Page 26: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan26

• Thm: The time complexity of Dinic’s algorithm is O(i|E|) for

type i network, where i = |E|1/2 if i = 0

|V|2/3 if i = 1

|V|1/2 if i = 2

Proof. (5/6)

Proof of Claim 1.

① i = 0: 0 = |E| / M*, 欲證: |E| / M* c00

∵ M* > 0, let 0 = √|E|, c0 = 1

|E| / M* |E| / 0 = |E| / √|E| = √|E| = 0.

② i = 1: 1 = 2|V| / √M*, 欲證: 2|V| / √M* c11

∵ M* > 1, let 1 = |V|2/3, c1 = 2

2|V| / √M* 2|V| / √1 = 2|V| / √|V|2/3 = 2|V|2/3 = c11.

§ 9.8 More

Page 27: Computer Science and Information Engineering National Chi ...erdos.csie.ncnu.edu.tw/~jsjuan/O11.pdf(c) Fall 2018, Justie Su-Tzu Juan 1 Computer Science and Information Engineering

(c) Fall 2018, Justie Su-Tzu Juan27

• Thm: The time complexity of Dinic’s algorithm is O(i|E|) for

type i network, where i = |E|1/2 if i = 0

|V|2/3 if i = 1

|V|1/2 if i = 2

Proof. (6/6)

Proof of Claim.

③ i = 2: 2 = (|V| 2) / M* + 1, 欲證: (|V| 2) / M* + 1 c22

∵ M* > 2, let 2 = √|V|, c2 = 2

(|V| 2) / M* + 1 (|V| 2) / 2 + 1

< |V| / 2 + 1

< |V| / √|V| + √|V|

= √|V| + √|V| = 2 √|V|

= 22 = c22.

§ 9.8 More