Code covered by the BSD License  

Highlights from
Vectorized Floyd-Warshall

5.0

5.0 | 1 rating Rate this file 20 Downloads (last 30 days) File Size: 1.49 KB File ID: #25776

Vectorized Floyd-Warshall

by Dustin Arendt

 

07 Nov 2009

Vectorized (fast) implementation of the Floyd-Warshall all pairs shortest path algorithm.

| Watch this File

File Information
Description

The Floyd-Warshall algorithm computes the all pairs shortest path matrix for a given adjacency matrix. The algorithm is O(n^3), and in most implementations you will see 3 nested for loops. This is very inefficient in Matlab, so in this version the two inner loops are vectorized (and as a result, it runs much faster).

Make sure that your input matrix is initialized properly -- A(i,j) = Inf if i and j are not neighbors.

MATLAB release MATLAB 7.9 (2009b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
12 Sep 2011 Hongxun JIANG

it is really fast.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
apsp Dustin Arendt 09 Nov 2009 10:51:27
all pairs shortest path Dustin Arendt 09 Nov 2009 10:51:27
shortest path Dustin Arendt 09 Nov 2009 10:51:27
network Dustin Arendt 09 Nov 2009 10:51:28
graph Dustin Arendt 09 Nov 2009 10:51:28
routing Dustin Arendt 09 Nov 2009 10:51:28
floyd Dustin Arendt 09 Nov 2009 10:51:28
floydwarshall Dustin Arendt 09 Nov 2009 10:51:28

Contact us at files@mathworks.com