Computer Networks · TEE · papers

Q4(a) · Dijkstra from u

2023-11-22 · AI-only Sem V variant; incomplete recovered scan

Exact historical variant. Current-syllabus questions solved; excluded topics and source limitations stated.

Q4(a). Using Dijkstra’s algorithm, calculate the shortest path from u to all nodes in the given undirected graph. Show every step. The complete original edge list is reproduced below. [10 marks]

Original diagram data

Edge endpoint1Endpoint2Cost
zx8
zy12
xy6
xv3
xw6
yv8
yt7
vt4
vu3
vw4
wu3
tu2

Answer

Given

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

Swipe across the diagram to read its labels ↔
Original undirected question graph: every edge weight retained; source u
Diagram: Original undirected question graph: every edge weight retained; source u. Labels: Original undirected question graph: every edge weight retained; source u | 8 | 12 | 6 | 3 | 6 | 8 | 7 | 4 | 3 | 4 | 3 | 2 | z | x | y | w | v | t | u
FromToCost
zx8
zy12
xy6
xv3
xw6
yv8
yt7
vt4
vu3
vw4
wu3
tu2

To find

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

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 improvementstuvwxyz
0Initial∞0∞∞∞∞∞
uv←u: 0+3=3; w←u: 0+3=3; t←u: 0+2=22033∞∞∞
ty←t: 2+7=92033∞9∞
vx←v: 3+3=6203369∞
wNo change203369∞
xz←x: 6+8=1420336914
yNo change20336914
zNo change20336914

Step 2. Read predecessors backwards, then reverse

DestinationDistancePreviousRoute
t2uu → t
u0—u
v3uu → v
w3uu → w
x6vu → v → x
y9tu → t → y
z14xu → v → x → z

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