Question

Consider the weighted undirected graph with 4 vertices, where the weight of edge {i,j}\{i, j\} is given by the entry WijW_{ij} in the matrix WW:

W=[02852058850x58x0]W = \begin{bmatrix} 0 & 2 & 8 & 5 \\ 2 & 0 & 5 & 8 \\ 8 & 5 & 0 & x \\ 5 & 8 & x & 0 \end{bmatrix}

The largest possible integer value of xx, for which at least one shortest path between some pair of vertices will contain the edge with weight xx is _____.

Official answer and solution
Official answer
12
From
Official GATE 2016 answer key

Solution

Find the shortest alternate path between vertices 3 and 4 that avoids edge {3, 4}.

We are given the 4-vertex distance matrix:

W=[02852058850x58x0]W = \begin{bmatrix} 0 & 2 & 8 & 5 \\ 2 & 0 & 5 & 8 \\ 8 & 5 & 0 & x \\ 5 & 8 & x & 0 \end{bmatrix}

The edge with variable weight xx is e={3,4}e = \{3, 4\}.

For edge {3,4}\{3, 4\} to be contained in at least one shortest path between some pair of vertices, it must at least be a shortest path between its own endpoints 3 and 4 (or contribute to another shortest path).

Find all alternate paths between vertex 3 and vertex 4 without using edge {3,4}\{3, 4\}:

  1. Path 3−1−43 - 1 - 4: weight =w(3,1)+w(1,4)=8+5=13= w(3, 1) + w(1, 4) = 8 + 5 = 13
  2. Path 3−2−43 - 2 - 4: weight =w(3,2)+w(2,4)=5+8=13= w(3, 2) + w(2, 4) = 5 + 8 = 13
  3. Path 3−2−1−43 - 2 - 1 - 4: weight =w(3,2)+w(2,1)+w(1,4)=5+2+5=12= w(3, 2) + w(2, 1) + w(1, 4) = 5 + 2 + 5 = 12

The minimum weight among all alternate paths connecting 3 and 4 is 12.
If x≤12x \le 12, the direct path 3−43 - 4 has weight x≤12x \le 12, which is less than or equal to the alternate path weight 12, making it a valid shortest path between 3 and 4.
If x>12x > 12, the path 3−2−1−43 - 2 - 1 - 4 has weight 12, strictly shorter than direct edge xx, and edge {3,4}\{3, 4\} cannot be part of any shortest path between any pair of vertices.

Therefore, the largest integer value of xx is 12.

Final answer

12

Common trap

Checking only 2-edge paths (3−1−43 - 1 - 4 and 3−2−43 - 2 - 4) giving 13, missing the 3-edge path 3−2−1−43 - 2 - 1 - 4 of length 12.

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

Source

Paper
GATE 2016 Computer Science and Information Technology (CS) Session 1
Question
48 of 65, printed as CS Q.38
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.