Computer Networks · TEE · papers

Q6(a) · Dijkstra six-node graph

2025-02-19 · 2023-24 / 2024-25

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

Q6(a). Consider the following network diagram comprising 6 nodes. Find the shortest path and shortest distance using Dijkstra’s Algorithm from A to every other node. Show all the intermediate steps. Show the table with shortest distance and previous node for all 6 nodes. [10 marks]

Original diagram data

FromToCost
AB3
AD7
BD5
BE5
DE4
DF2
EF1
EC8
FC3

Answer

Given

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

Swipe across the diagram to read its labels ↔
dijkstra 2025 original question graph
Diagram: dijkstra 2025 original question graph. Labels: dijkstra 2025 original question graph | 3 | 7 | 5 | 5 | 4 | 2 | 1 | 8 | 3 | A | B | C | D | E | F
FromToCost
AB3
AD7
BD5
BE5
DE4
DF2
EF1
EC8
FC3

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; D←A: 0+7=703∞7∞∞
BE←B: 3+5=803∞78∞
DF←D: 7+2=903∞789
EC←E: 8+8=160316789
FC←F: 9+3=120312789
CNo change0312789

Step 2. Read predecessors backwards, then reverse

DestinationDistancePreviousRoute
A0—A
B3AA → B
C12FA → D → F → C
D7AA → D
E8BA → B → E
F9DA → D → F

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