Question

Let G(V,E)G(V, E) be an undirected, edge-weighted graph with integer weights. The weight of a path is the sum of the weights of the edges in that path. The length of a path is the number of edges in that path.

Let s∈Vs \in V be a vertex in GG. For every u∈Vu \in V and for every k≥0k \ge 0, let dk(u)d_k(u) denote the weight of a shortest path (in terms of weight) from ss to uu of length at most kk. If there is no path from ss to uu of length at most kk, then dk(u)=∞d_k(u) = \infty.

Consider the statements:

S1: For every k≥0k \ge 0 and u∈Vu \in V, dk+1(u)≤dk(u)d_{k+1}(u) \le d_k(u).

S2: For every (u,v)∈E(u, v) \in E, if (u,v)(u, v) is part of a shortest path (in terms of weight) from ss to vv, then for every k≥0k \ge 0, dk(u)≤dk(v)d_k(u) \le d_k(v).

Which one of the following options is correct?

Choose one option
Official answer and solution
Official answer
A
From
Official GATE 2026 answer key

Solution

Check monotonicity of dk(u)d_k(u) in kk (S1) and test S2 when a shorter-hop path to vv exists or when edge weights are negative.

  1. S1 is true: Let Pk(u)\mathcal{P}_k(u) be the set of paths from ss to uu of length at most kk. Since Pk(u)⊆Pk+1(u)\mathcal{P}_k(u) \subseteq \mathcal{P}_{k+1}(u), taking the minimum path weight over a larger set of allowed paths can only decrease or keep the minimum unchanged: dk+1(u)≤dk(u)d_{k+1}(u) \le d_k(u).
  2. S2 is false: Consider a graph with vertices {s,a,u,v}\{s, a, u, v\} and edges (s,a)(s, a) of weight 11, (a,u)(a, u) of weight 11, (u,v)(u, v) of weight 11, and a direct edge (s,v)(s, v) of weight 1010. The unique shortest path from ss to vv in terms of weight is s−a−u−vs - a - u - v (weight 33, length 33), which contains (u,v)(u, v). However, for k=1k = 1, there is a 1-edge path from ss to vv of weight 1010 (d1(v)=10d_1(v) = 10), whereas there is no path from ss to uu of length at most 11 (d1(u)=∞>d1(v)d_1(u) = \infty > d_1(v)). (Moreover, if (u,v)(u, v) has a negative integer weight, dk(v)d_k(v) can also be strictly less than dk(u)d_k(u).)
Final answer

Option (A)

Common trap

Assuming dk(u)≤dk(v)d_k(u) \le d_k(v) holds for every kk just because d(u)≤d(v)d(u) \le d(v) holds for unconstrained non-negative shortest paths.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2026 Computer Science and Information Technology - Session 1 (CS1)
Question
41 of 65
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.