A distance oracle is said to have (α, β) stretch if for every x, y ∈ V it satisfies…
- User
A distance oracle is said to have (α, β) stretch if for every x, y ∈ V it satisfies dist(x, y) ⩽ db(x, y) ⩽ α · dist(x, y) + β. Show that for any n vertex unweighted graphs you can compute a distance oracle of stretch (3, 2) that takes O(n^2log^2 n) pre-processing time
- Assistant
To compute a distance oracle of stretch (3, 2) for an unweighted graph with n vertices, we can use the following algorithm:
-
Preprocessing: a. Initialize an n x n matrix D, where D[i][j] represents the distance between vertices i and j. b. For each vertex v in the graph, perform a breadth-first search (BFS) starting from v and compute the distances to all other vertices.
- This can be done in O(n^2) time by running BFS for each vertex v and updating the matrix D. c. Compute the matrix B, where B[i][j] = min(D[i][j], D[j][i]) for all i, j in {1, 2, ..., n}.
-