function T = inc_to_google ( A )

%*****************************************************************************80
%
%% inc_to_google() converts an incidence matrix to a Google transition matrix.
%
%  Discussion:
%
%    If the input incidence matrix has a node I with no connectivity,
%    (A(I,1:N) = 0) then we artificially set T(1:N,I)=1/N, so that
%    the transition matrix property of having unit column sums is preserved.
%
%    For nodes with connectivity, we assume that 85 percent of the time
%    we will take a link at random, and 15 percent of the time, we will
%    jump to an arbitrary link.  
%
%  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 );
  T = zeros ( size ( A ) );

  s = sum ( A, 2 );
  for i = 1 : n
    if ( s(i) == 0.0 )
      T(i,:) = 1.0 / n;
    else
      T(i,:) = 0.85 * A(i,:) / s(i) + 0.15 / n;
    end
  end

  T = T';

  return
end
