1 / 9

The single-source shortest path problem

The single-source shortest path problem. 許智凱. The Single-Source Shortest Path Problem. The single-source shortest path problem 是要用來尋找所有由同一個源點到達圖上每一個節點的最短路徑 . 給予一個連接的有向圖形 G =( V , E ), 且每條邊的權重皆不為負值 . This weight can be considered as the length of this edge.

prisca
Télécharger la présentation

The single-source shortest path problem

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The single-source shortest path problem 許智凱

  2. The Single-Source Shortest Path Problem • The single-source shortest path problem是要用來尋找所有由同一個源點到達圖上每一個節點的最短路徑. • 給予一個連接的有向圖形G=(V,E),且每條邊的權重皆不為負值. This weight can be considered as the length of this edge. • 由於是要尋找最短路徑,等同於花費最少的成本到達每個節點,同為Greedy method.

  3. The Single-Source Shortest Path Problem • Shortest paths from v0 to all of the other vertices are found one by one. The nearest neighbor of v0 is first found. Then the second nearest neighbor of v0 is found. This processis repeated until the nth nearest neighbor of v0 is found where n is the number of vertices in the graph other than v0.

  4. Source set: S Vertices - S: V-S

  5. Dijkstra’s Algorithm Input:有向圖G= (V, E) 與源點v0. 取得與v0相連每 個點的邊上權重c. |V|= n + 1. Output: 對於每個vÎ V, 所取得的權重最小值 S: = {v0} Fori : = 1 to n do Begin If (v0, vi) ÎE then L(vi) : = c(v0, vi) else L(vi) : = ¥ End

  6. Dijkstra’s Algorithm For i : = 1 to n do Begin Choose u from V - S such that L(u) is thesmallest S : = S ∪{u} (* Put u into S *) For all w in V - S do L(w) : = min(L(w), L(u) + c(u, w)) End

  7. Example: 01234 30 0 0 2 01030 4 0102530 010253029 4 15 10 10 10 1 3 20

  8. Example: ABCDE 0 10 3 2 B D 0 7 3 11 5 10 0 7 3 9 5 A 4 8 9 3 C E 2

  9. Time Complexity • Time = Ω(V·取得連接邊的權重c +E·比較最小權重邊並取代) Binary Heap: V·logV+E·logV → E· logV Fibonacci Heap: (E+ V· logV) E

More Related