9-2 ?? ( Graph ) - PowerPoint PPT Presentation

1 / 92
About This Presentation
Title:

9-2 ?? ( Graph )

Description:

_____ – PowerPoint PPT presentation

Number of Views:74
Avg rating:3.0/5.0
Slides: 93
Provided by: ks91
Category:
Tags: algorithm | graph | prims

less

Transcript and Presenter's Notes

Title: 9-2 ?? ( Graph )


1
? ? ?????
???????? ????________
2
??????
1.????????????????? 2.??????????????????
3
????
9-1 ??????? 9-2 ?? ( Graph ) 9-3 ?????? 9-4
???? 9-5 ??????? 9-6 ??? ( Spanning Tree ) 9-7
??????? ( Minimum Cost Spanning Tree ) 9-8 ???? (
shortest path ) 9-8 ???? ( Topological Sort )
4
9-1 ???????
???????????????,????????(Eular)??????????????,????
??????????????????????????????????,?????????,????
?????,???????????9-1??
5
?????(Eular)??????????,????(Vertices)???????,?(Edg
e)???????,??9-2??
6
??9-2?,??????????????????????????,??????????,?????
??,???????????????????,????????????(A?????5,B?????
3,C?????3,D?????3),?????????????????????????,????
??,??????????
7
9-2 ?? ( Graph )
???? ??(Graph)????(Vertices)??(Edges)???,?G(V,E)?
????V????????,E???????????? V
Vertex(???????),V(G)V1,V2,V3,,Vm,?? mgt0 E
Edge(????),E(G)E1,E2,E3,,En,??ngt0
8
????,???????????????(Undirected
Graph)? ????(Directed Graph)??,????? 1.
????(Undirected Graph) (1) ?(Edges)????????
(2) ?(V1,V2)??(V2,V1)????? 2. ????(Directed
Graph) (1) ?(Edges)??????? (2)
?ltV1,V2gt??ltV2,V1gt?????? (3) ltV1,V2gt,??V1??(head
),V2??(tail),????V1??V2
9
???????(A) ?????,???(Vertices)??(Edges)??????? V(
G)A,B,C,D,E E(G)(A,B),(A,C),(B,A),(B,D),(C,A)
,(C,E),(D,B) ,(D,E) ,(E,C) ,(E,D)
??(A)????????,????????????, ????????( )??
10
??(B)??????????????????, ?ltgt???? ????? V(G)A,B,
C,D,E E(G)ltA,Bgt,ltA,Cgt,ltB,Dgt,ltC,Egt,ltD,Egt
11
??????(Self Loop)???(Multi Edges)???,????????, ???
????????
12
??????????????????
1. ???? ( complete graph ) (1)????????,??n???,?
????n(n-1)/2??, ??????????
(2)????????,??n???,?????n(n-1)??,?
?????????
13
2. ?? ( path )
??? G ?,??????????????,??9-5??(A)?,A?E????(A,B),
(B,E)?(A,C), (C,E)?(A,B),(B,D),(D,E)???,?????
????
14
3. ???? ( simple path )
?????(?????)???(??????)???????????????????????????
???????????????????????9-5??(A)?,(A,B),(B,D),(D,E
),(E,C),(C,A)???????A,??????????
????? A ?????,?? C , E , B ?????, ?? B , D , E 
,  B ????????
15
4. ???? ( cycle )????
???????????????????B , D , E  ,  B ?
16
5. ??(Sub-graph)
? G(V,E) ? G(V,E) ???,?V?V?E?E
17
6. ??(Connected)
??????,???Vi???Vj?????,?Vi?Vj????? 7.
????(Connected Graph) ????G?,?????????,??????????,
??????????
18
8. ????(Connected Component)
?????????(Maximal Connected Subgraph),??????2?????
?
19
9. ????(Strongly Connected)
?????(Directed Graph)??,?????ltVi,Vjgt ??????? Vi ?
Vj ??????????Vj? Vi???(Directed Graph)
20
10. ??(Adjacent)
(1)???G(V,E) ?u,v?V,(u,v)?E,??u,v????????
???? u ??? v ?? (2)???G(V,E) ?u,v?V,ltu,vgt?E
?? u ???(Adjacent To)v ?? v ???(Adjacent
From)u
21
11. ????(Path Length)
???? k ???????(Edge)????
22
12.???(Degree)
(1)???G(V,E) ?? u ??????? u
?????,??9-3??(A)?A?? ?????2? (2)???G(V,E)
????? ( in - degree )??????v???????????
?9-3??(B)?,A ????????0,?E????????
2?(?????? v) ????? ( out - degree
)?????????,??????? v???????????9-3??(B)?,A
????????2, ?E????????0?(????? v ???)
23
?????????????????? ???? (1)???? (2)???? (3)???
?????? (4)?????? (5)??????
24
9-3 ??????
???,??????????????,???????(Adjacency
Matrix)?????(Adjacency Lists)???????(Adjacency
Multi lists)?????(Indexed Table)?
25
9-3.1 ???? ( Adjacency Matrix )
???? ???G ( V , E ) ??? n ??????,??n gt
1?,??????G ?????,???????? n n ????????,???????
( adjacency matrix ) ? ???? 1. ??Aij 0
???E(i,j)??? 2. ??Aij 1 ???E(i,j)?? 3.
??????????????,AijAij
26
(No Transcript)
27
???(A)??????????,?Aij1?,?????G?????(Vi,Vj)???
??,?Aij0?,?????G??????(i,Vj)??? ???????,????i
????????????? ?????(A)??????????,??1????4?
28
???(B)??????????,?Aij1?,?????G?????ltVi,Vjgt???
??,?A  ij0?,?????G??????ltVi,Vjgt??? ???????,??
???????????,???????????????????(B)??????????,??1?
????3,?????1?
29
????????,?????????????????????,??,?????????,??????
?????????????,?????????,?????????????
30
???????????????????
31
9-3.2 ???? (Adjacency Lists)
???? ????G(V,E)??n???(n?1)?,???????n???????????,?
????????????????????????????????,?????????,???????
?0???,???1?????????
32
???? 1.???????????? 2.?????,n???e????n???????2e??
? ?????n???????e??????????,????
?????????????O(ne)?
33
??????
????????????????2??????,????? ?????????????
???? ????
34
???1??????????( undirected  graph
)??????? ???????,5???7????5???????14???,
??,??????,????????2??
????
35
???2??????????( directed  graph )???????
???????, 5???7????5???????7???,
??,??????,??????????
36
9-4 ????
???????,????????????????,?????????????????????????
?,????????????????????????,???????????????????????
?????????????????????(weight),????????????????????
?????,??9-6???1???2????????6?
37
9-4.1 ?????????????
????????????????? ,??????????????????,????????????
???????????,??1???,??,??0??????????????????,??
???????,??,?? ??????9-6???????,????????????????
??
38
9-4.2 ?????????????
??????????????,??????????????????????????????????
??9-6???????,?????????????????
39
9-5 ???????
?????????????????(??)??,??????????????,???????????
?????????????????(Depth-First-Search,DFS)????????(
Breadth-First-Search,BFS)?
40
9-5.1 ??????? ( Depth-First Search DFS )
???? 1.?????????????(Stack)????? 2.???????????????
?????,??????? ????????????????????????????
??????????????,?????????,??? ??????????????????
41
????
(1)??????? V? (2)????????V ????????????? W ,? W
? ?????????? (3) ?????????????????,?????????
????,????????? (4) ??????????,???????????????
?,????????
42
???? ( Stack ) ????
?????????,???? ?????????????,???? 1 , 2 ,
4 , 8 , 5 , 6 , 3 , 7 ????????????
43
(No Transcript)
44
(No Transcript)
45
(No Transcript)
46
(No Transcript)
47
9-5.2 ??????? ( Bradth First Search
BFS )
???? 1. ?????????????(Queue)???????????? 2.
????????????????????,????????
?????????????????????????????
?????????????,?????????,????? ????????????????
48
????
1. ?????????Qu 2. ?????? v ??? Qu
??(????Enqueue??) 3. ?? Qu ???,???????,?????? 4
3.1 ? Qu?????? w(????Dequeue??) 3.2 ?? w
????????? 3.3 ???? w ??????????????????? Qu
?? (????Enqueue??) 3.4 ???? 3 4. ??
49
????(Queue)???
?????????,????? ????????????
50
(No Transcript)
51
(No Transcript)
52
(No Transcript)
53
9-5.3 DFS?BFS??
1.???????(DFS)???(????)??,??????
??????????????? 2.???????(BFS)???(???)??,?????????
????????
54
9-5.4 DFS?BFS??
????????????? 1.????????????(spanning
tree) 2.???????????????(connected
graph) 3.????????????
55
9-6 ??? ( Spanning Tree )
????????????????????,??????n????????,?????????????
,????????????????,???????,????????????,???????????
????,????????????????????????(spanning
tree)?????????,?????????,????????,?????,??????????
?????,????????????,?????????????????,?????????
56
???? ??G (V,E)?????,? S ( V,T ) ? G ??????? T
??????????,??K ?????????????,????????????? 1. E
T K???9-7?? 2. V ??????? V1 ? V2 ,? S
??????? 3. ?? K ??????? S ?,????????9-8??
57
9-7 ??????? ( Minimum Cost Spanning Tree )
?????????????????????,???????????????(weight),????
????????????,?????????????????????????,???????????
????????(minimum-cost spanning tree)?
58
(No Transcript)
59
???????,?9-10??(1)???????(2)????????????,????????,
??,?????????????????????????,????????????-Kruskal?
???Prime???(????K??P????)???????,????????????????(
greedy strategy)?
60
9-7.1 Kruskal ???
???? Kruskal ????????? Weight ????,???T?,????????
Spanning tree,???????,????? n-1
????????????????????,????????,?????? T ???????? T
????????????,???? T ?,?? G?????? n gt 0 ???,???? n
- 1 ?????? T ??
61
????
???n????????,?Kruskal??????? 1.????????????? 2.??
????????????????,???????,??? ??????
(1)????,??????MST?,????2? (2)?????,????MST?,???
???(n-1)??? ??3,??????2? 3.Kruskal????MST,?
??
62
??????Kruskal ?????????????????
63
??1???????????????
64
(No Transcript)
65
(No Transcript)
66
(No Transcript)
67
9-7.2 Prims ???
???? ???????G (V,E) ,?? V1,2,3,...,n,?????
U1,U,V ????????,?????????????? U-V
????????V,??U???????????????,?????V??U??,?????,??U
????V?????
68
??????Prims ?????????????????
69
(No Transcript)
70
(No Transcript)
71
(No Transcript)
72
9-8 ???? ( shortest path )
????( shortest path )?????????????????????????????
???????????,?????????????????,?????????,??????? 1
.?????????????? 2.????????????
73
???????????????,?????????????(??)????(??)?????(???
),????????,???????????,??????????,??????????,?????
??,??,???????????????????????,???????? Dijkstra's
algorithm ???
74
????
?? 1 DI AF,I ( I 1 , N ) S F
V 1 , 2 , 3 , .... , N ??D? N
??????,???????????????????
F ??????????? A F,I ??? F ?? I
????? V ????????????
S ????????
75
?? 2 ? V-S ??????? t ?? Dt ????,?? t ??
S ??,??? V-S ??????? ?? 3 ?????????
D ?????? DI min(DI,DtAt,I) ?? I ??
t ??????? ?????? 2 ???
76
????
???????????????
77
(No Transcript)
78
(No Transcript)
79
(No Transcript)
80
(No Transcript)
81
(No Transcript)
82
(No Transcript)
83
lt?gt?????
84
(No Transcript)
85
(No Transcript)
86
9-9 ????( Topological Sort )
?????(Activity)???????????????,??????????,????????
?,??????????,?????????????????????,???????????,???
??????????????????????,???????????????????????(Act
ivity On Vertex Network),???AOV???
87
???? ?? AOV?? ?,Vi ? Vj ????,????????,Vi ??? Vj
???,??????????? ( Topological Sort ) ???
AOV???????????? (1) ? AOV?????????????????? (2)
?????,????????????????? (1) ???
,??????????????
88
???? ???????????,????????????????????????????????
??????????????????????
89
???? ??? AOV???????
90
(No Transcript)
91
(No Transcript)
92
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com