Shortest path distances of all node pairs
returns
a matrix, d
= distances(G
)d
, where d(i,j)
is
the length of the shortest path between node i
and
node j
. If the graph is weighted (that is, G.Edges
contains
a variable Weight
), then those weights are used
as the distances along the edges in the graph. Otherwise, all edge
distances are taken to be 1
.
optionally
specifies the algorithm to use in computing the shortest path using
any of the input arguments in previous syntaxes. For example, if d
= distances(___,'Method
',algorithm)G
is
a weighted graph, then distances(G,'Method','unweighted')
ignores
the edge weights in G
and instead treats all edge
weights as 1
.
digraph
| graph
| nearest
| shortestpath
| shortestpathtree