Skip to main content

GATE CSE 2003Algorithms › Graph AlgorithmsVerified

GATE CSE 2003 PYQ: Let G = ( V , E ) G =(V,E) G = ( V , E ) be an undirected graph with a subgraph G 1 = ( V 1 , E 1 ) G_1 =…

Let G=(V,E)G =(V,E) be an undirected graph with a subgraph G1=(V1,E1)G_1 = (V_1, E_1). Weights are assigned to edges of GG as follows.

w(e)={0, if e∈E11, otherwisew(e) = \begin{cases} 0 \text{, if } e \in E_1 \\1 \text{, otherwise} \end{cases}

A single-source shortest path algorithm is executed on the weighted graph (V,E,w)(V,E,w) with an arbitrary vertex v1v_1 of V1V_1 as the source. Which of the following can always be inferred from the path costs computed?

  1. A
    The number of edges in the shortest paths from v1v_1 to all vertices of GG
  2. B
    G1G_1 is connected
    Correct answer
  3. C
    V1V_1 forms a clique in GG
  4. D
    G1G_1 is a tree

Answer

(B) G 1 G_1 G 1 ​ is connected

Approach

Edges of the subgraph G1 have weight 0, while all other edges have weight 1. Therefore, a shortest-path cost of 0 from the source v1 to a vertex in V1 is possible exactly when that vertex can be reached using only edges of E1. If every vertex in V1 gets distance 0, then G1 is connected; if some vertex in V1 gets positive or infinite distance, then G1 is disconnected.

The edge weights are 0 exactly on the subgraph G1. Therefore the computed shortest-path distances from v1 reveal whether every vertex of V1 is reachable from v1 using only zero-weight edges, which is equivalent to G1 being connected. Nothing about edge counts, cliques, or tree structure follows from the distance values.

Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.