Computer Networks · TEE · papers

Q2(a) · Dijkstra from w

2024-02-06 · AI-only Sem V variant

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

Q2(a). Using Dijkstra’s algorithm calculate shortest paths from w to all nodes in the original graph. Show all steps; the complete edge list is 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 = w.

Swipe across the diagram to read its labels ↔
Original undirected question graph: every edge weight retained; source w
Diagram: Original undirected question graph: every edge weight retained; source w. Labels: Original undirected question graph: every edge weight retained; source w | 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 w.

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∞∞∞
wu←w: 0+3=3; x←w: 0+6=6; v←w: 0+4=4∞3406∞∞
ut←u: 3+2=553406∞∞
vy←v: 4+8=125340612∞
tNo change5340612∞
xz←x: 6+8=14534061214
yNo change534061214
zNo change534061214

Step 2. Read predecessors backwards, then reverse

DestinationDistancePreviousRoute
t5uw → u → t
u3ww → u
v4ww → v
w0—w
x6ww → x
y12vw → v → y
z14xw → x → z

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