Floyd-Warshall Algorithm

Created on 2022-06-24T10:23:38-05:00

Return to the Index

This card pertains to a resource available on the internet.

This card can also be read via Gemini.

Compute the cost of the shortest path between every pair of nodes.

Does not work if some paths result in a negative cost.

n = no of vertices
A = matrix of dimension n*n
for k = 1 to n
    for i = 1 to n
        for j = 1 to n
            Ak[i, j] = min (Ak-1[i, j], Ak-1[i, k] + Ak-1[k, j])
return A