Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dijkstra animation. Dijksta’s Algorithm (Shortest Path Between 2 Nodes) 2 Phases:initialization;iteration Initialization: 1. Included:(Boolean) 2. Distance:(Weight)

Similar presentations


Presentation on theme: "Dijkstra animation. Dijksta’s Algorithm (Shortest Path Between 2 Nodes) 2 Phases:initialization;iteration Initialization: 1. Included:(Boolean) 2. Distance:(Weight)"— Presentation transcript:

1 Dijkstra animation

2 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

3 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; Dijkstra’s Algorithm

4 t f f - A A A - - ft t t B B ft - 4 2 5 ∞ ∞ F ft 10 8 9 Dijkstra 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.


Download ppt "Dijkstra animation. Dijksta’s Algorithm (Shortest Path Between 2 Nodes) 2 Phases:initialization;iteration Initialization: 1. Included:(Boolean) 2. Distance:(Weight)"

Similar presentations


Ads by Google