IAE Academy

GATE 2025 CS2 Q.37: solution and answer

GATE 2025 · CS2Q.37 · 2 marks · MCQ

Let be an edge-weighted undirected graph with positive edge weights. Suppose a positive constant is added to the weight of every edge.

Which ONE of the following statements is TRUE about the minimum spanning trees (MSTs) and shortest paths (SPs) in before and after the edge weight update?

  1. (A)

    Every MST remains an MST, and every SP remains an SP.

  2. (B)

    MSTs need not remain MSTs, and every SP remains an SP.

  3. (C)

    Every MST remains an MST, and SPs need not remain SPs.

  4. (D)

    MSTs need not remain MSTs, and SPs need not remain SPs.

See the question in the paper

Answer and solution

ANSWER

The correct answer is (C) Every MST remains an MST, and SPs need not remain SPs.

Official answer: CSource: Official answer key, GATE 2025 CS2 (IIT Roorkee)

  1. Since has vertices, every spanning tree of has exactly edges (a basic property of trees) — this holds for EVERY spanning tree, not just the MST.

  2. After adding to every edge weight, the new total weight of any spanning tree is , because contributes exactly edges to the sum, each of which increased by .

  3. Crucially, the shift is the SAME constant for every spanning tree of — it depends only on and , never on which particular tree is chosen.

  4. Adding an identical constant to every value in a set cannot change which value is the minimum. So whichever spanning tree(s) had minimum weight before the update still have minimum weight after it: every MST remains an MST.

  5. Now consider shortest paths between two vertices and . Unlike spanning trees, different candidate paths from to can use different numbers of edges — say one path uses edges and another uses edges.

  6. After adding to every edge, a path using edges gains total weight . Since in general, the two candidate paths are shifted by DIFFERENT amounts, not the same amount as in the spanning-tree case.

  7. This unequal shift can reverse the relative order: a path that was shortest before the update (possibly using more edges but a smaller original total weight) can end up longer than a path using fewer edges once is added to every edge — a standard counterexample exists for any such setup.

  8. Hence shortest paths need not remain shortest paths after the update, while every MST is guaranteed to remain an MST.

  9. This matches option (C): Every MST remains an MST, and SPs need not remain SPs.

KEY IDEA

Every spanning tree of a connected graph on vertices has exactly edges, so adding a constant to every edge shifts every spanning tree's total weight by the SAME fixed amount — this cannot change which tree has minimum weight. But different simple paths between two vertices can use different numbers of edges, so the same shift adds different amounts to different candidate paths, which can flip which path is shortest.

WATCH OUT FOR

Assuming that because MSTs are preserved under a uniform additive shift, shortest paths must be too — students forget that different u-v paths can use different numbers of edges, so the shift is NOT applied equally to all candidate paths (unlike spanning trees, which always have exactly n−1 edges regardless of which tree is chosen).

From the GATE 2025 CS2 paper. Every question of this paper · Download the full paper · All 28 Graph algorithms questions, with notes

More Graph algorithms questions