GATE Computer ScienceHardGATE CSE · UGC NET

A directed graph on vertices 0–4 has edges 0→1 (3), 0→3 (7), 1→0 (8), 1→2 (2), 2→0 (5), 2→3 (1), 3→0 (2), 3→4 (4), 4→2 (3). What is the sum of the shortest-path distances over all 25 ordered pairs (u, v), including the zero diagonal?

  1. A. 91
  2. B. 96
  3. C. 101
  4. D. 106

Correct answer: B. 96

Floyd–Warshall on the 5×5 matrix yields a total of 96.

More Algorithms questions

Exams that ask this topic