IAE Academy

GATE 2024 CS2 Q.59: solution and answer

GATE 2024 · CS2Q.59 · 2 marks · NAT

The number of distinct minimum-weight spanning trees of the following graph is ____.

Graph description: Vertices a, b, c, d, e, f, g. Edges and weights:
- a-b: 1
- a-f: 1
- a-g: 2
- b-c: 3
- b-g: 2
- c-g: 2
- c-d: 1
- g-f: 2
- g-e: 2
- g-d: 2
- f-e: 3
- e-d: 1

GATE 2024 CS2 question 59: An undirected weighted graph with 7 vertices: a, b, c, d, e, f, g.Tap to open full size
Figure from the GATE 2024 CS2 paper. It is part of the question.
Figure description

An undirected weighted graph with 7 vertices: a, b, c, d, e, f, g. Positions roughly: a (far left), b (top left), c (top right), d (far right), f (bottom left), e (bottom right), g (center). Edges: a-b weight 1, a-f weight 1, a-g weight 2, b-c weight 3, b-g weight 2, c-g weight 2, c-d weight 1, g-f weight 2, g-e weight 2, g-d weight 2, f-e weight 3, e-d weight 1. g is connected to all six other vertices (a,b,c,d,e,f), each with weight 2.

Answer and solution

ANSWER

The number of distinct minimum-weight spanning trees is .

Official answer: 9Source: Official answer key, GATE 2024 CS2 (IISc Bengaluru)

  1. List edge weights: weight 1 — a-b, a-f, c-d, d-e; weight 2 — g-a, g-b, g-c, g-d, g-e, g-f (g joins every other vertex at cost 2); weight 3 — b-c, f-e.

  2. The four weight-1 edges a-b, a-f, c-d, d-e form no cycle (they build a star at a covering {a,b,f} and a path at d covering {c,d,e}), so they are a valid forest.

  3. Each of these four edges is forced into every MST by the standard MST exchange property: for a tree edge candidate of weight 1, if it were excluded from some MST T, the path joining its endpoints inside T would have to use only edges of weight ≤ 1 (otherwise swapping in the weight-1 edge would strictly improve T). Checking each: no all-weight-1 path exists between a and b, between a and f, between c and d, or between d and e using only the other three weight-1 edges (each attempt dead-ends at a vertex with no further weight-1 edge). Hence a-b, a-f, c-d, d-e belong to every minimum spanning tree.

  4. After fixing these 4 edges, the graph has collapsed into 3 components: X = {a,b,f}, Y = {c,d,e}, and the isolated vertex g. A spanning tree needs exactly 2 more edges to merge 3 components into 1, and those 2 edges must connect the components without forming a cycle (i.e. they must together touch all of X, Y, g).

  5. Only three edges leave g toward X (a-g, b-g, f-g, each weight 2) and three leave g toward Y (c-g, e-g, d-g, each weight 2); the only edges directly between X and Y are b-c and f-e, each weight 3.

  6. Enumerate the ways to pick 2 edges that span all three components: (i) one X-g edge + one Y-g edge → cost 2+2 = 4, and this spans X, g, Y; (ii) one X-g edge + one X-Y edge → cost 2+3 = 5; (iii) one Y-g edge + one X-Y edge → cost 2+3 = 5; using two X-Y edges, or two edges both from X to g (or both from Y to g), never touches all three components, so those are not spanning. The minimum extra cost is 4, achieved only by case (i): one edge from g to X and one edge from g to Y.

  7. Total minimum weight = (1+1+1+1) from the four forced edges + 2 + 2 = 8.

  8. Count the minimum-weight spanning trees: choose 1 of the 3 edges {a-g, b-g, f-g} to attach g to X, and independently 1 of the 3 edges {c-g, e-g, d-g} to attach g to Y. Each of the 3 × 3 = 9 combinations, together with the 4 forced weight-1 edges, gives a distinct acyclic spanning tree of total weight 8, and no other combination reaches weight 8.

  9. Hence the number of distinct minimum-weight spanning trees is 3 \times 3 = 9.

KEY IDEA

First pin down every edge that must belong to every MST (via the cut/exchange property — here the four disjoint weight-1 edges), which collapses the graph into a few components; then count only the ways to connect the remaining components at minimum extra cost, treating each such choice as an independent factor.

WATCH OUT FOR

Assuming that whichever edges look "cheapest overall" must all be forced, without checking (via the exchange/cut argument) that no equal-or-cheaper alternative path connects their endpoints; or, when counting, forgetting to verify that a candidate pair of connecting edges (e.g. two edges from the same component to g, or two direct X–Y edges) actually spans all remaining components before including it in the count — this can silently over- or under-count the multiplicative total.

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

More Graph algorithms questions