Graph Theory Chapter 13 Graph Algorithms 2011 10
- Slides: 21
Graph Theory Chapter 13 Graph Algorithms 大葉大學 資訊 程系 黃鈴玲 2011. 10
Contents Ø Ø 13. 4 13. 5 13. 6 13. 7 Breadth-First Search Depth-First Search Connected Components Dijkstra’s Shortest Path Algorithm 2
13. 4 Breadth-First Search 先進先出 Three operations: (1) Enqueue(Q, u): adds u to the tail of Q. (2) Dequeue(Q): removes one item from the head of the nonempty queue Q and returns that element. (3) Empty(Q): returns True if Q is empty, False otherwise. 3
Example 13. 5 T 1 T 2 T 3 T 4 T 5 s y=6 Q: 1 6 8 5 9 x=1 5
source 2 7 4 3 6
7
Ex: Find a BFS forest for the following graph G with source v 1. (下標小的優先選) G v 12 v 5 v 13 v 8 v 2 v 7 v 6 v 15 v 4 v 10 v 14 v 9 v 3 v 11 8
13. 5 Depth-First Search 9
10
Ex: Find a DFS forest for the following graph G with source v 1. (下標小的優先選) G v 12 v 5 v 13 v 8 v 2 v 7 v 6 v 15 v 4 v 10 v 14 v 9 v 3 v 11 11
13. 6 Connected Components Component number 1 2 3 4 1 1 3 2 2 2 4 用DFS拜訪所有點 1 4 4 2 1 12
13
13. 7 Dijkstra’s Shortest Path algorithm 加Father[. ] of size n: 記錄shortest path的上一點 Father[i] =1 if W 1 i Father[u] =v if pathcost[u] = pathcost[v] +Wuv 14
第 1個for迴圈 Father[3] =1 source Father[4] =1 Umin={3 } 15
第 2個for迴圈 Father[3] =1 i=1 Father[2] =3 source Father[5] =3 Father[6] =3 Father[4] =3 Umin={4 } 16
Father[3] =1 i=2 Father[2] =3 source Father[5] =4 Father[6] =3 Father[4] =3 Umin={5 } 17
Father[3] =1 i=3 Father[2] =3 source Father[5] =4 Father[6] =5 Father[4] =3 Umin={2 } 18
Father[3] =1 i=4 Father[2] =3 source Father[5] =4 Father[4] =3 Father[6] =2 end 19
u 0 Source Ex 16 10 v 1 13 v 6 pathcost v 7 17 6 14 5 7 v 4 minimum v 3 father v 2 v 5 9 11 v 2 v 1 8 v 3 v 4 v 5 v 6 v 7 U {v 1, …, v 7 ( , -) (13, u 0) ( , -) (16, u 0) (8, u 0) ( , -) {v}1, …, v 7}-v 5 ( , -) ( , -) (18, v 5) (25, v 5) (15, v 5) ( , -) {v 1, v 3, v 4, v 6, v 7} {v 1, v 3, v 6, v 7} ( , -) (18, v 5) (20, v 4) ( , -) (18, v 5) (13, u 0) (25, v 5) (15, v 5) ( , -) Shortest u 0 -v 3 path: u 0, v 5, v 4 {v 3, v 6, v 7} {v 6, v 7} Ch 4 -20
Ex: Find the distances from 1 to x for each x=2, 3, …, 8, and determine their shortest paths. 5 2 4 1 2 2 3 1 5 2 4 5 3 5 21
- Elementary graph algorithms
- Parallelizing sequential graph computations
- Elementary graph algorithms
- Undirected graph algorithms
- Handshaking theorem
- Game theory and graph theory
- Computational thinking algorithms and programming
- Algorithms types
- Simple recursive algorithms
- 1001 design
- Handling patients
- Recursive algorithms
- Types of randomized algorithms
- Process mining algorithms
- Evolution of logistics ppt
- Nature-inspired learning algorithms
- Tabu search tsp
- Making good encryption algorithms
- Algorithm analysis examples
- Statistical algorithms
- Professor ajit diwan
- What is greedy