Machine-translated by Google. Questions are authored in English.
Top

Discussion

Weighted undirected graph on nodes A to I; each edge carries its label e1 to e18 and its weight

V = {A, B, C, D, E, F, G, H, I}
E = {e1 = (A, B), e2 = (A, C), e3 = (A, D), e4 = (B, C), e5 = (B, F), e6 = (B, H), e7 = (C, D), e8 = (C, E), e9 = (C, F), e10 = (D, E), e11 = (D, I), e12 = (E, F), e13 = (E, G), e14 = (F, G), e15 = (F, H), e16 = (G, H), e17 = (G, I), e18 = (H, I)}
W = {22, 9, 12, 35, 36, 34, 4, 33, 30, 18, 23, 24, 39, 25, 21, 19}

The weight of the shortest path from node A to I in the undirected graph is........... .

  • A.2
  • B.3
  • C.42
  • D.43

Answer: C

The shortest path from A to I has weight 42.

Reading the weights from the figure, the cheap edges near A are A-C (9), A-D (12) and C-D (4), and D connects straight to I with weight 30. Running Dijkstra's algorithm from A:

  • A = 0; then C = 9, D = 12 (A-C-D would be 13), B = 22.
  • From D: I = 12 + 30 = 42 and E = 12 + 33 = 45.
  • Every other route to I is longer: through H it is at least 22 + 34 + 19 = 75, and through G at least 45 + 23 + 21 = 89.

\[ \begin{aligned} d(A,I) &= w(A,D) + w(D,I) \\ &= 12 + 30 = 42 \end{aligned} \]

43 is the path A-C-D-I, \(9 + 4 + 30\), which looks attractive because it starts with the cheapest edge but ends one unit heavier. 2 and 3 count edges rather than adding weights: A-D-I has two edges.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.