GATE / CS ARCHIVE

GATE CSE 2003 / QUESTION 67

Detecting subgraph connectivity with zero-weight edges

Algorithms · Graph Algorithms · Full GATE CSE 2003 paper

GATE 2003, Q67 2 marks · MCQ
Report issue

Graph Algorithms

Question 67, GATE 2003: G=(V,E) is an undirected graph with subgraph G1=(V1,E1). Give an edge weight 0 if it is in E1, and 1 otherwise. Run single-source shortest paths from an arbitrary v1∈V1. Which property can always be inferred from the computed path costs?
A. Number of edges in shortest paths from v1 to every vertex of G
B. G1 is connected
C. V1 forms a clique in G
D. G1 is a tree
Interpret B as determining whether G1 is connected, not asserting connectivity on every input.
Question 67, GATE 2003: G=(V,E) is an undirected graph with subgraph G1=(V1,E1). Give an edge weight 0 if it is in E1, and 1 otherwise. Run single-source shortest paths from an arbitrary v1∈V1. Which property can always be inferred from the computed path costs?
A. Number of edges in shortest paths from v1 to every vertex of G
B. G1 is connected
C. V1 forms a clique in G
D. G1 is a tree
Interpret B as determining whether G1 is connected, not asserting connectivity on every input.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. With only weights 0 and 1, a finite path has total cost 0 precisely when all of its edges belong to E1.
2. Hence d(v1,v)=0 precisely for vertices in the G1 component of v1. Test this for every v∈V1: all distances zero means G1 is connected; any positive/infinite distance means it is not.
3. Cost does not count zero-weight edges. A zero-weight chain and a zero-weight clique on V1 can give identical distance-zero results but different edge counts and cycle structure.
4. Thus the distances determine connectivity (B), but neither clique/tree status nor shortest-path edge counts.

Solution: An edge has weight zero exactly when it belongs to E1. Consequently, for a vertex v in V1, distance(v1,v)=0 exactly when v is connected to v1 using only edges of G1. Checking whether every vertex of V1 has zero distance therefore decides whether G1 is connected, B. Zero distances do not reveal edge counts, clique structure, or acyclicity: a tree and a triangle within the reachable zero-weight component can have identical distances. B must be read as determining connectivity, not asserting that every possible input G1 is connected.

Original paper, page 9