Professional Documents
Culture Documents
Dijkstras Algorithm
Networks
Maps are examples of a real life networks.
Wiltshire
Networks
Wiltshire
shortest path between two places. In the past you used to look on a map and plan the route yourself. These days there are websites that will do this for you.
http://www.theaa.com/travelwatch/planner_main.jsp
http://www.cs.utexas.edu/users/EWD/
Wiltshire
influential members of computing science's founding generation. Among the domains in which his scientific contributions are fundamental are
algorithm design programming languages program design operating systems distributed processing formal specification and verification design of mathematical arguments
Dijkstra`s Algorithm.
the grid below.
Wiltshire
O T
Dijkstra`s Algorithm
to find the shortest route from S to T.
Wiltshire
Dijkstra`s Algorithm
Give the start node a permanent label of 0. The 1 indicates that this is the first node to receive a
Wiltshire
permanent label.
Look at all the nodes which can be reached from the start node in one
edge. Thats A, D and F. Give them a temporary label of their distance from the start node.
Wiltshire
Dijkstra`s Algorithm
Wiltshire
Make the lowest temporary node permanent. This is node A in this case. If there had been more than one, then you could choose any.
Look at all the nodes you can reach from A without a permanent label.
Wiltshire
Make the lowest temporary node permanent. This is node D in this case.
Wiltshire
Wiltshire
Wiltshire
Wiltshire
Wiltshire
Wiltshire
Wiltshire
The shortest path will be marked with a red line. To find it you work backwards from T to S identifying whose length
Wiltshire
Dijkstra`s Algorithm
is the same as the difference between the permanent labels at either end.
Dijkstra`s Algorithm
Wiltshire
Dijkstra`s Algorithm
Wiltshire
Why do we assign temporary labels? The algorithm systematically searches for the quickest route to
every node. We assign a temporary label as that stands for the current quickest route to that node. Later in the algorithm an alternative route may be found so we replace the temporary label with a new temporary label.
Dijkstra`s Algorithm
It is the start point , you have not travelled anywhere.
Wiltshire
Why does the first node get assigned permanent label zero?
Wiltshire
10 8 10
4 6
15 10 15
3 3 3
10 9 10
Wiltshire
Dijkstras Algorithm
Introduction
with weights assigned to their edges:
Wiltshire
Airline flight times Telephone communication costs Computer networks response times
Wheres my motivation?
Fastest way to get to school by car
Wiltshire
Wiltshire
25 19
The Red Garter
9
the beach (dude)
16
In N Out
3 1
My cardboard box on Sunset
21
36
Wiltshire
Dijkstras
Wiltshire
(2,A) 2
E
7 3 2
F
(9,B) ( ,-) 3
Wiltshire
2
A
Source
1
G (6,A)
( ,-) (4,B)
( ,-) (6,E) 2 2
H ( ,-)
( ,-) (10,H)
Destination
4
(5,E) (9,G) (8,F)
Pseudocode
1. Include Source node (A) in LIST. Let A be the workingnode(x). 2. Label all other nodes as < Weight(edge between node & A) , A > 3. Pick out the node with smallest label; let it become the new working node x; include x in LIST 4. Check whether re-labeling is essential for all other* nodes and re-label (if necessary): * those not included in LIST Let every node ask the following question
Wiltshire
Has a shorter route surfaced after including new working node(x) in LIST? OR (more technically) Is my label bigger than the quantity Label(x) + w( x, myself ) ? If answer is YES (re-labeling essential), re-label node as < Label(x) + w(x, itself), x > 5. Now trace from dest. Node with the help of labels back to source. You get the shortest path between Source Dest.