"All Pairs Shortest Path" Graph Solver
by Michael Kleder
24 Oct 2005
(Updated 26 Dec 2007)
No BSD License
Gives the shortest node-to-node distance along the edges of a graph for all node combinations.
Download Now
|
Watch this File
|
| File Information |
| Description |
ALLSPATH - solve the All Pairs Shortest Path problem
Rapidly returns the shortest node-to-node distance along the edges of a graph, for all nodes in the graph.
USAGE: B = allspath(A)
A = input distance matrix between nodes
B = shortest path distance matrix between all nodes
Notes:
(1) For a graph with n nodes, A is an n-by-n distance matrix giving the distances between adjacent nodes. Since the distance from point i to point j is the same as the distance from point j to point i, A must be a symmetric matrix
(2) The distance from a node to itself can either be entered as zero or infinity. (Either will produce a correct result.) This means that the diagonal elements of the matrix A must all be either zero or infinity.
(3) The distance between nodes that are not adjacent to each other must be entered as either zero or infinity. (Either will produce a correct result.) This means that the (i,j) and (j,i) elements of A, where i and j are non-adjacent nodes, must all be either zero or infinity.
(4) If the input graph is not "connected," meaning that some nodes cannot be reached from other nodes no matter how many edges are traversed, then the distances between nodes that cannot be connected will be returned as infinite.
(5) Distances between a node and itself are returned as zero.
(6) This function codifies an original algorithm created by the author.
(7) No warranties; use at your own risk.
(8) Written by Michael Kleder, October 2005. |
| Acknowledgements |
This submission has inspired the following:
Advanced Dijkstra's Minimum Path Algorithm
|
| MATLAB release |
MATLAB 7.0.4 (R14SP2)
|
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Comments and Ratings (10) |
| 09 Dec 2005 |
LIU Jerry
|
|
|
| 26 Apr 2006 |
giuseppe d
|
|
|
| 27 Apr 2006 |
giuseppe d
|
|
|
| 29 Jun 2006 |
Kyaw Tun
|
|
|
| 16 Oct 2006 |
Dead Beat
|
|
|
| 26 Oct 2006 |
David Leamer
|
|
|
| 14 Apr 2007 |
John S
|
|
|
| 18 May 2007 |
Joseph Kirk
|
|
|
| 21 May 2007 |
The Author
|
|
|
| 23 May 2007 |
Joseph Kirk
|
|
|
| Updates |
| 26 Oct 2005 |
typographical updates to comments and file exchange page |
| 22 May 2007 |
Replaced a Statistics Toolbox function call from the provided example for use by users without the Statistics Toolbox. |
| 26 Dec 2007 |
Fixed a bug in the example. (An index variable had been omitted. Thanks to Joseph Kirk for pointing out the bug.) |
|
MATLAB Central Terms of Use
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Terms prior to use.
Contact us at files@mathworks.com