function B = r8mat_floyd ( A )

%*****************************************************************************80
%
%% r8mat_floyd() finds the shortest R8 distances between pairs of nodes in a directed graph.
%
%  Discussion:
%
%    We assume we are given the adjacency matrix A of the directed graph.
%
%    We assume that A is an R8MAT, that is, a two-dimensional array of R8's.
%
%    The adjacency matrix is NOT assumed to be symmetric.
%
%    If there is not a direct link from node I to node J, the distance
%    would formally be infinity.  We assume that such distances are assigned
%    the value R8_HUGE.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    05 March 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real A(N,N), the one-step distance from node I to node J.
%
%  Output:
%
%    real B(N,N), the shortest total distance from node I to node J.
%
  n = size ( A, 1 );
  B = A;

  for k = 1 : n
    for j = 1 : n
      for i = 1 : n
        B(i,j) = min ( B(i,j), B(i,k) + B(k,j) );
      end
    end
  end

  return
end
