function path_dist = graph_dist_all ( dist, nnode )

%*****************************************************************************80
%
%% graph_dist_all() finds the distance from every node to every other node.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    05 November 2024
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Alan Gibbons,
%    Algorithmic Graph Theory,
%    Cambridge University Press, 1985,
%    ISBN 0-521-28881-9.
%
%  Input:
%
%    real DIST(NNODE,NNODE).
%    DIST(I,J) is the length of the edge FROM node I TO node J.
%    DIST(I,J) = Inf if there is no direct edge from I to J.
%
%    integer NNODE, the number of nodes.
%
%  Output:
%
%    real PATH_DIST(NNODE,NNODE).  This array contains the
%    lengths of the shortest paths from each node to another node.
%    PATH_DIST(I,J) is the length of the shortest path from node I
%    to node J.  If PATH_DIST(I,J) = Inf, there is no path from node
%    I to node J.
%
  for k = 1 : nnode

    for i = 1 : nnode
      for j = 1 : nnode

        path_dist(i,j) = dist(i,j);

        if ( dist(i,k) ~= Inf && dist(k,j) ~= Inf )

          path_dist(i,j) = min ( path_dist(i,j), dist(i,k) + dist(k,j) );

        end

      end
    end

    dist = path_dist;

  end

  return
end
