function T = incidence_to_transition ( A )

%*****************************************************************************80
%
%% incidence_to_transition() converts an incidence matrix to a transition matrix.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    29 February 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer A(N,N), the incidence matrix.
%
%  Output:
%
%    real T(N,N): the transition matrix.
%
  n = size ( A, 1 );
%
%  Get the row sums.
%
  s = sum ( A, 2 );
%
%  Normalize each row so it sums to 1.
%
  T = zeros ( n, n );
  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
