Computer Networks · TEE · papers

Q3(a) · Dijkstra from t

2022-11-16 · AI-only Sem V

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

Q3(a). Using Dijkstra’s algorithm, determine the shortest path from t to all nodes. Show all necessary steps; the original graph’s complete 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 = t.

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

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
0Initial0∞∞∞∞∞∞
tu←t: 0+2=2; y←t: 0+7=7; v←t: 0+4=4024∞∞7∞
uw←u: 2+3=50245∞7∞
vx←v: 4+3=7024577∞
wNo change024577∞
xz←x: 7+8=1502457715
yNo change02457715
zNo change02457715

Step 2. Read predecessors backwards, then reverse

DestinationDistancePreviousRoute
t0—t
u2tt → u
v4tt → v
w5ut → u → w
x7vt → v → x
y7tt → y
z15xt → v → x → z

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