Floyd-Warshall (vectorized)
Version 2.0.0 (2.3 KB) by
Giorgos Dim
[fixed version] Vectorized Floyd-Warshall algorithm to find shortest paths and distances between every node pair.
Provides both shortest paths' distances and a function to get the path itself. If you only need the distances use FloydWarshall(D) instead of FloydWarshallWithPaths(D) because its somewhat faster.
Code being vectorized means the inner loops are replaced with matlab commands which make it run faster on a lower level, though the algorithm's time complexity remains O(n^3) where n is the number of nodes.
It's good for dense graphs, while for sparse graphs it's better to use Johnson's algorithm.
See ExampleUsage.m file for how to use.
Cite As
Giorgos Dim (2024). Floyd-Warshall (vectorized) (https://www.mathworks.com/matlabcentral/fileexchange/172800-floyd-warshall-vectorized), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2024b
Compatible with any release
Platform Compatibility
Windows macOS LinuxTags
Acknowledgements
Inspired by: Floyd-Warshall (vectorized)
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
2.0.0 |