50 likes | 241 Views
Dijkstra animation. Dijksta’s Algorithm (Shortest Path Between 2 Nodes). 2 Phases:initialization;iteration Initialization: 1. Included:(Boolean) 2. Distance:(Weight) initialize to 0 if START weight if an edge from START to index
E N D
Dijksta’s Algorithm(Shortest Path Between 2 Nodes) 2 Phases:initialization;iteration Initialization: 1. Included:(Boolean) 2. Distance:(Weight) initialize to 0 if START weight if an edge from START to index ∞ if no edge (not adjacent) 3. Path:(node) Contains immediate predecessor initialize to: START if adjacent undefined if not adjacent
Dijkstra’s Algorithm Iteration: repeat find node j with smallest distance, not already included; for each R not included and adjacent to J if distance[j]+edgeweight(J,R)<distance[R] then distance[R]:=distance[J]+edgeweight(J,R); Path[R]:=J; endif; until destination node is included;
- - 4 A 2 A 5 A - ∞ - ∞ Dijkstra t f t f t f t F B f t 10 9 f t B 8 Give the shortest path tree for node A for this graph using Dijkstra’s shortest path algorithm. Show your work with the 3 arrays given and draw the resultant shortest path tree with edge weights included.