1 / 6

9.3 – Dijkstra's Algorithm

- Used to solve the single-source shortest paths problem for weighted connected graphs → Start at a vertex designated as the source → Find shortest paths to all other vertices - Some uses for this problem: i . Transportation planning ii. Packet routing of communication networks

robbin
Download Presentation

9.3 – Dijkstra's Algorithm

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. - Used to solve the single-source shortest paths problem for weighted connected graphs → Start at a vertex designated as the source → Find shortest paths to all other vertices - Some uses for this problem: i. Transportation planning ii. Packet routing of communication networks iii. Searching social networks iv. Speech Recognition 9.3 – Dijkstra's Algorithm

  2. Dijkstra's Algorithm - Applies to directed and undirected graphs with non negative weights only - Finds shortest paths to all vertices in order of distance from the source vertex. → The weights of the edges in the graph are used as measure of distance - A sub-tree of the graph is made based on the vertices already visited by the algorithm. - The set of vertices that are adjacent to the current sub-tree are called “fringe vertices” → candidates the algorithm will choose the next element from

  3. Dijkstra's Algorithm - To determine the next closest vertex → a) For every fringe vertex, compute distance to nearest vertex 'v' of the sub-tree → b) Then, add the length of the shortest distance from the source vertex to 'v' to the value obtained in (a) → c) Fringe vertex with the lowest computed sum becomes the next

  4. Required Data - Each vertex 'v' should hold two values → d – the shortest distance from the source node to vertex 'v' → a link to the parent node of the current vertex 'v' - Once a fringe node 'u' has been identified as the next node in the tree → Move node 'u' from the fringe vertex list to the set of tree vertices → For all remaining fringe nodes adjacent to node 'u' calculate if the distance from the source node to 'u' + the distance from 'u' to the fringe node is less than the current distance associated with the fringe node. If it is, replace the current distance with the new distance

  5. The Algorithm ALGORITHM Dijkstra(G, s) //Dijkstra’s algorithm for single-source shortest paths //Input: A weighted connected graph G = V, E with non-negative weights // and its vertex s //Output: The length dv of a shortest path from s to v // and its penultimate vertex pvfor every vertex v in V Initialize(Q) //initialize priority queue to empty for every vertex v in V dv ←∞; pv←null Insert(Q, v, dv) //initialize vertex priority in the priority queue ds ←0; Decrease(Q, s, ds) //update priority of s with ds VT←∅ for i←0 to |V| − 1 do u∗ ←DeleteMin(Q) //delete the minimum priority element VT ←VT ∪ {u∗} for every vertex u in V − VT that is adjacent to u∗ do If du∗ + w(u∗, u) < du du ←du∗ + w(u∗, u); pu←u∗ Decrease(Q, u, du)

  6. Efficiency For graphs represented by their weight matrix and the priority queue implemented as an unordered array, it is in Θ(|V |2) For graphs represented by their adjacency lists and the priority queue implemented as a min-heap, it is in O(|E| log |V |)

More Related