How to find shortest path length by adjacency matrix?

29 views (last 30 days)
If I have adjacency matrix(i.e matrix that represent connection between nodes in a network) , i want to get matrix that its (i,j) represent the minimum number of steps from i node to j node giving adjacency matrix.
Thanks.

Accepted Answer

Matt J
Matt J on 14 May 2021
Edited: Matt J on 14 May 2021
Use the adjacency matrix A to create a graph object, and then use the distances() command.
distanceMatrix=distances(graph(A))

More Answers (0)

Categories

Find more on Graph and Network Algorithms in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!