Dijkstras Algorithm for Finding Shortest Paths - PowerPoint PPT Presentation

PPT – Dijkstras Algorithm for Finding Shortest Paths PowerPoint presentation | free to view - id: d2272-MGNiN

The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
Title:

Dijkstras Algorithm for Finding Shortest Paths

Description:

Dijkstra's Algorithm for Finding Shortest Paths. Initially only the source node s is settled. ... We find the node v that is unsettled. We settle v by ... – PowerPoint PPT presentation

Number of Views:150
Avg rating:3.0/5.0
Slides: 9
Provided by: IRE62
Category:
Tags:
Transcript and Presenter's Notes

Title: Dijkstras Algorithm for Finding Shortest Paths

1
Dijkstras Algorithm for Finding Shortest Paths
• Irena Pevac

2
Shortest Paths
• Def The distance along the path is the sum of
the labels of that path.
• Def The minimum distance from node u to node v
is the minimum of the distance on any path from u
to v.
• Dijkstra algorithm gives efficient way to find
the minimum distance from the source node to all
the nodes of the graph. Graph can be either
directed or undirected.

3
Settled and Unsettled Nodes
• We discover the minimum distance from the source
to other nodes in the order of those distances.
• We will call settled nodes those nodes for which
we know their minimum distance.
• The set of settled nodes always includes source.
• For unsettled nodes v, we record the length of
the shortest path that starts at the source,
travels only through settled nodes, and at last
step jumps out of the settled region to v.

4
Dijkstras Algorithm for Finding Shortest Paths
• Initially only the source node s is settled. Its
distance to the source dist(s)0.
• If there is an arc from s to u dist(u) is the
label of that arc. If there is no arc from s to
u, the dist(u)?.
• Assume that some nodes are settled. We find the
node v that is unsettled. We settle v by
• Make dist(v) to be the min distance from s to v.
• Adjust the value of dist(u) for all nodes u that
remain unsettled, to account for the fact that v
is now settled.

5
Example
6
Start at A
7
Dijkstra(G,s)
• for every vertex v in V
• dv ?
• Insert (Q, v, dv) // initialize vertex
priority in PQ
• Dist(s)0
• Decrease(Q,s,dist(s))
• For i 0 to V-1
• uDeleteMin(Q)
• VTVT U u
• for every vertex u in V-VT that is adjacent
to u
• if (dist(u) label(u,u) lt dist(u))
• dist(u) dist(u)
label(u,u)
• u is settled.
• Decrease(Q,u,dist(u))

8
Time efficiency for Dijkstras Algorithm
• Let G(V,E) Vn Em
• Let graph be represented with weight adjacency
matrix, and priority queue be implemented as an
unordered array.
• Time is ?(n2).
• Let graph be represented with weight adjacency
lists, and priority queue be implemented as a min
heap.
• Time is ?( m logn).