演算法›Ch4 圖論演算法第 68 題/共 111 題
68. Dijkstra's Algorithm、Pseudocode
#AL-04-068易Dijkstra's AlgorithmPseudocode
- Please refer to the following pseudo code and find which statements are true.
1 function f(Graph, source):
2 for each vertex v in Graph: // Initialization
3 dist[v] := infinity
4 previous[v] := undefined
5 dist[source] := 0
6 Q := the set of all nodes in Graph
7 while Q is not empty: // main loop
8 u := node in Q with smallest dist[ ]
9 remove u from Q
10 for each neighbor v of u:
11 alt := dist[u] + dist_between(u, v)
12 if alt < dist[v]
13 dist[v] := alt
14 previous[v] := u
15 return previous[ ]
📄 交大111
▤完整推導請見《WH 資工筆記 · 演算法》Ch4 圖論演算法