Our task is to find shortest paths between every pair of nodes. Floyd-Warshall is a graph algorithm for finding shortest paths in weighted graph. The input of a function will be in weighted adjacency matrix representation. If two vertices does not have any edge than this matrix has Inf value. Function will return a matrix with values of shortest paths between each pair of nodes.
Example :
input= [0 1 Inf Inf
Inf 0 2 Inf
Inf Inf 0 3
4 7 Inf 0]
output= [0 1 3 6
9 0 2 5
7 8 0 3
4 5 7 0]

Solution Stats

51 Solutions

28 Solvers

Last Solution submitted on Feb 24, 2026

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers28

Suggested Problems

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!