Skip to content
Official PYQ · 2003

GATE CS 2003 Q67 — Shortest Paths (Dijkstra, Bellman-Ford)

Explain with AI

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?

Choose one option
View worked solution

Answer: B

To understand what can be inferred from the computed shortest path costs, let us analyze how the edge weights affect the path costs from the source vertex v1∈V1v_1 \in V_1:

  • Edges belonging to the subgraph G1G_1 (i.e., e∈E1e \in E_1) have a weight of 00.
  • All other edges in GG (i.e., e∉E1e \notin E_1) have a weight of 11.

Let d(v1,u)d(v_1, u) denote the shortest path cost from the source v1v_1 to any vertex u∈V1u \in V_1. Since all edge weights are non-negative, d(v1,u)≥0d(v_1, u) \ge 0.

Analyzing Connectivity of G1G_1:

  1. If G1G_1 is connected: For every vertex u∈V1u \in V_1, there exists a path from v1v_1 to uu consisting entirely of edges in E1E_1. Since each of these edges has weight 00, the total cost of this path is 00. Thus, the shortest path cost d(v1,u)=0d(v_1, u) = 0 for all u∈V1u \in V_1.
  2. If G1G_1 is disconnected: There exists at least one vertex u∈V1u \in V_1 that is not in the same connected component as v1v_1 within G1G_1. Any path from v1v_1 to uu in GG must traverse at least one edge not in E1E_1 (which has weight 11). Therefore, the shortest path cost d(v1,u)≥1d(v_1, u) \ge 1.

By checking if the computed shortest path cost from v1v_1 to all other vertices in V1V_1 is exactly 00, we can uniquely determine (infer) whether G1G_1 is connected.

Eliminating Other Options:

  • Option A: Since edges in E1E_1 have weight 00, they do not contribute to the path cost. Thus, we cannot determine the actual number of edges in the shortest path.
  • Option C: Path costs from a single source cannot determine if every pair of vertices in V1V_1 has an edge between them (clique property).
  • Option D: Path costs of 00 cannot detect the presence of cycles consisting of 00-weight edges, so we cannot infer if G1G_1 is a tree (acyclic).

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Shortest Paths (Dijkstra, Bellman-Ford) questions