function T = digraph_adj_to_transition ( A )

%*****************************************************************************80
%
%% digraph_adj_to_transition() converts an adjacency matrix to a transition matrix.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    12 September 2024
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer A(N,N), the adjacency matrix.
%
%  Output:
%
%    real T(N,N): the transition matrix.
%

%
%  Get the number of variables.
%
  n = size ( A, 1 );
%
%  Get the row sums.
%
  s = sum ( A' );
%
%  Allocate T.
%
  T = zeros ( n, n );
%
%  Normalize each row so it sums to 1.
%
  for i = 1 : n
    if ( s(i) ~= 0.0 )
      T(i,:) = A(i,:) / s(i);
    else
      T(i,i) = 1.0;
    end
  end
%
%  Transpose the matrix.
%
  T = T';

  return
end
