Let be an undirected graph with a subgraph . Weights are assigned to edges of as follows.
A single-source shortest path algorithm is executed on the weighted graph with an arbitrary vertex of as the source. Which of the following can always be inferred from the path costs computed?
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 :
- Edges belonging to the subgraph (i.e., ) have a weight of .
- All other edges in (i.e., ) have a weight of .
Let denote the shortest path cost from the source to any vertex . Since all edge weights are non-negative, .
Analyzing Connectivity of :
- If is connected: For every vertex , there exists a path from to consisting entirely of edges in . Since each of these edges has weight , the total cost of this path is . Thus, the shortest path cost for all .
- If is disconnected: There exists at least one vertex that is not in the same connected component as within . Any path from to in must traverse at least one edge not in (which has weight ). Therefore, the shortest path cost .
By checking if the computed shortest path cost from to all other vertices in is exactly , we can uniquely determine (infer) whether is connected.
Eliminating Other Options:
- Option A: Since edges in have weight , 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 has an edge between them (clique property).
- Option D: Path costs of cannot detect the presence of cycles consisting of -weight edges, so we cannot infer if is a tree (acyclic).
Free practice · Your answers on this page are not saved.
