Floyd Warshall All Pairs Shortest Path Flashcards

1
Q

Term

A

Definition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

All-Pairs Shortest Path (APSP)

A

Find the shortest path between every pair of vertices in a graph. If there are n vertices, compute n^2 shortest paths.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Distance Matrix D

A

A matrix where D[i][j] stores the shortest path distance from vertex i to vertex j.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Next Matrix N

A

A matrix where N[i][j] stores the next vertex to visit on the shortest path from i to j.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

APSP using Dijkstra

A

Run Dijkstra’s algorithm from every vertex (only works with non-negative edge weights). Time complexity: O(V(E + V log V)).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

APSP using Bellman-Ford

A

Run Bellman-Ford from every vertex. Handles negative weights. Time complexity: O(V^2E).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Floyd-Warshall Algorithm

A

Dynamic programming algorithm that computes shortest paths between all pairs. Time complexity: O(V^3).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Floyd-Warshall D_k[i][j]

A

Shortest path from i to j using only intermediate nodes ≤ k.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Floyd-Warshall Base Case D_0

A

D_0[i][j] = weight(i,j) if edge exists; 0 if i==j; ∞ otherwise.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Floyd-Warshall Recurrence

A

D_k[i][j] = min(D_{k-1}[i][j], D_{k-1}[i][k] + D_{k-1}[k][j]).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Floyd-Warshall Next Matrix Update

A

If D_k[i][j] updated via path through k, then N[i][j] = N[i][k]; otherwise, N[i][j] = N[i][j].

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Matrix Multiplication Method

A

D^k[i][j] = shortest path from i to j with ≤ k edges. Built using min-plus matrix multiplication.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Min-Plus Matrix Multiplication

A

Special multiplication: replace addition with min, and multiplication with +.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Repeated Squaring

A

Efficiently compute D^n via powers of 2: D^1, D^2 = D^1D^1, D^4 = D^2D^2, etc. Time: O(n^3 log n).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Transitive Closure

A

Graph with edges (i,j) if there is a path from i to j. Can be computed using APSP with boolean logic.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Transitive Closure via Boolean Matrix

A

Replace shortest path weights with True/False. Use AND and OR instead of min and +.