第 五 章 图 论 ( 第二部分 )

Post on 25-Jan-2016

85 views

Category:

Documents

DESCRIPTION

TRANSCRIPT

• ()

1.

2.

3.

• [] ()

eW(e) (u, v)(u,v)W(u,v)

(1) W(uu) = 0 (u, u) E(G), (2) W(uv) = , (u, v) E(G)

[]

• : W(a,b)=5W(a,a)=0W(b,d)=W(a,d)=8

• []Guvuvuv

• AFBCDE

• acac(a, b, c)5+4=9;(a, c)12;(a, d, c)8+20= 28 abcac9

• (Dijkstra)G=(V,E)az (1) aV-{a}P1P1t1; t1 = zP1az (2)(2) a V-{a,t1}P2P2t2 t2 = zP2az (3)(3) aV-{a,t1,t2}P3P3t3 t3= zP3az (4)(4) kPkz

• G=(V, E)Gaz

[]T(1) T V(2) z T, z(3) a T, a

[] t1 Tat1Tt1TDT(t1).T={c, e, f, g, z}, DT(c).acT:(a, b, c): : 1+2 = 3(a, c): : 4(a, d, c): : 4+3 = 7 DT(c) = 3TG

• []: T = {t1, t2, , tn}, t1TDT(t1) = min{DT(t1), DT(t2) , , DT(tn)} (1) at1DT(t1) (2) 2 in at1 atiT = {e, f, g, z}, DT( e ) = 9; DT( f ) = 6;DT( g ) = 8; DT( z ) = ; Taf afDT(f)=6G

• 1 (1) () at1DT(t1). DT(t1)at1TDT(t1)T

• 2

() dnew dnew < DT(t1) t2T dnew = DT(t2) + W(t2t1) > DT(t1) w(t2t1) t2t1 dnew < DT(t1) at1DT(t1).aTt1t2

• 2

() (2) () ti(i2) atiat1Pdd

• G=(V, E)az 1T1V-{a}T1t1 t1=zDT1(t1)az 2 2T2=T1-{t1},T2t2 t2=z,DT2(t2)az (3) 3 TkzTk DTk(z)az

Ti

• Tm={tm, tm+1, , tn}DTm(ti)tiTtm Tm+1= Tm {tm}ti tmtntm+1tmTmTm+1tmtiW(tm,ti)

• G=(V, E)az

[](1) T = V {a}(2) vTDT(v)=W(a,v) (3) TtTTT{t} (4) t = zDT(z)az t z v TDT(v)=min(DT(v), DT(t)+W(t,v)) (3).

DT(z)az

• az

a

b

e

z

c

f

d

g

1

9

1

2

6

2

4

3

4

4

3

7

5

6

3

• T1{b,c,d,e,f,g,z}: DT1(b) = 1 ab DT1(c) = 4 ac DT1(d) = 4 ad DT1(e) = DT1(f) = DT1(g) = DT1(z)=

T1bbab

a

b

e

z

c

f

d

g

1

9

1

2

6

2

4

3

4

4

3

7

5

6

3

• cT2abcadabeacabc,DT2(c)=3 DT1(b) = 1 ab DT1(c) = 4 ac DT1(d) = 4 ad DT1(e) = DT1(f) = DT1(g) = DT1(z)=

a

b

e

z

c

f

d

g

1

9

1

2

6

2

4

3

4

4

3

7

5

6

3

T3

a

b

e

z

c

f

d

g

1

9

1

2

6

2

4

3

4

4

3

7

5

6

3

• T4T3{d}={e, f, g, z}T4 abceabcfabcgT4fDT4(f)=6afabcfaf

T4

a

b

e

z

c

f

d

g

1

9

1

2

6

2

4

3

4

4

3

7

5

6

3

• T4egDT5(e)=8aeabcfeae

T5T4{f}={e, g, z} T5 abcfeT5abcgabcg

a

b

e

z

c

f

d

g

1

9

1

2

6

2

4

3

4

4

3

7

5

6

3

• T6T5{e}={g, z} T6 T6T6fDT6(g)=6agabcgag

abcgabcfez

a

b

e

z

c

f

d

g

1

9

1

2

6

2

4

3

4

4

3

7

5

6

3

• T7T6{g}={z} T7 azDT7(z)=9 abcfezabcfezT7

a

b

e

z

c

f

d

g

1

9

1

2

6

2

4

3

4

4

3

7

5

6

3

• (1) T1=V {a} 1T1

• (2) T2=T1{b} T2t T23T2T1T1

• T3=T2{ c }T34T2T1T3

• ezfezcfezbcfezabcfez

bcdefgz44410968988109

• az

• 561T11

• 2694T2T1

• 36987T2T1T3

• 498117T3T2T4

• 598913T4T3T5

• : abcghzT1T2T3T4T5T6T7T8

• u0c

• Dijkstra u0edc

• P20335

DT(t1)at1at1dnew < DT(t1)

DT(t1)at1TDT(t1)T

t2Tdnew = DT(t2) + w(t2t1)

dnew < DT(t1)

DT(t2) < DT(t1)

at2at1 t1T DT(t1) = min{DT(t1), DT(t2) , , DT(tn)}DT(t1)at1at1dnew < DT(t1)

DT(t1)at1TDT(t1)T

t2Tdnew = DT(t2) + w(t2t1)

dnew < DT(t1)

DT(t2) < DT(t1)

at2at1 t1T DT(t1) = min{DT(t1), DT(t2) , , DT(tn)}DT(t1)at1at1dnew < DT(t1)

DT(t1)at1TDT(t1)T

t2Tdnew = DT(t2) + w(t2t1)

dnew < DT(t1)

DT(t2) < DT(t1)

at2at1 t1T DT(t1) = min{DT(t1), DT(t2) , , DT(tn)}