Computer Networks · TEE · papers

Q7(a) · Dijkstra graph

2024-02-06 · 2022-23

Actual paper; 100 marks attempted. Current-syllabus alignment is stated per question.

Q7(a). Determine the shortest path and shortest distance from source vertex A to every other vertex in the following graph using Dijkstra’s Algorithm. Illustrate step-by-step procedure and draw shortest path table. [10 marks]

Original diagram data

FromToCost
AB3
AC5
BC9
BD8
BE6
CE3
DE10
DF3
EF5

Answer

Given

The original diagram is undirected. All edge labels are reproduced below. Source = A.

Swipe across the diagram to read its labels ↔
dijkstra 2024 original question graph
Diagram: dijkstra 2024 original question graph. Labels: dijkstra 2024 original question graph | 3 | 5 | 9 | 8 | 6 | 3 | 10 | 3 | 5 | A | B | C | D | E | F
FromToCost
AB3
AC5
BC9
BD8
BE6
CE3
DE10
DF3
EF5

To find

Shortest distance, complete route and predecessor for every node from A.

Formula and why

d(v)\leftarrow\min(d(v),d(u)+w(u,v))LaTeX: d(v)\leftarrow\min(d(v),d(u)+w(u,v))

Relaxation replaces a tentative route when going through u is cheaper. Dijkstra settles the unvisited node of least tentative distance. Nonnegative edge costs make the settled distance final. Equal-distance nodes may be settled in either order.

Step 1. Initialize and relax

Pass / settled nodeStrict improvementsABCDEF
0Initial0∞∞∞∞∞
AB←A: 0+3=3; C←A: 0+5=5035∞∞∞
BD←B: 3+8=11; E←B: 3+6=9035119∞
CE←C: 5+3=8035118∞
EF←E: 8+5=1303511813
DNo change03511813
FNo change03511813

Step 2. Read predecessors backwards, then reverse

DestinationDistancePreviousRoute
A0—A
B3AA → B
C5AA → C
D11BA → B → D
E8CA → C → E
F13EA → C → E → F

A tie between two equally short paths is valid; this table retains the first predecessor on equal distances.