function google_rank ( A )

%*****************************************************************************80
%
%% google_rank() uses the power method on the Google matrix.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 February 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer A(N,N): the incidence matrix.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'google_rank():\n' );
  fprintf ( 1, '  Given an NxN incidence matrix A,\n' );
  fprintf ( 1, '  compute the Google matrix G,\n' );
  fprintf ( 1, '  Then start with a vector of N values 1/N,\n' );
  fprintf ( 1, '  and repeatedly compute x <= G*x\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  After many steps, compare last three iterates.\n' );
  fprintf ( 1, '  If they are close, we are probably at an eigenvector\n' );
  fprintf ( 1, '  associated with the eigenvalue 1.\n' );

  n = size ( A, 1 );
%
%  Compute the Google matrix.
%
  G = inc_to_google ( A );
%
%  Set the starting vector.
%
  x = ones ( n, 1 ) / n;
%
%  Carry out many iterations.
%  Normalization is not necessary because G is a transition matrix.
%
  for i = 1 : 100

    x = G * x;

  end
%
%  Compare three successive iterates.
%
  x1 =     x;
  x2 = G * x1;
  x3 = G * x2;

  r8vec3_print ( n, x1, x2, x3, '  x, G*x, G*G*x' );

  return
end
