function [ a, h ] = hits_iteration ( A, k )

%*****************************************************************************80
%
%% hits_iteration carries out the HITS algorithm as an iteration.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    23 December 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real A(M,N), the system matrix.
%
%    integer K, the number of iterations.
%
%  Output:
%
%    real A(N), the authority indices.
%
%    real H(N), the hub indices.
%
  [ m, n ] = size ( A );
  a = ones ( n, 1 );
  h = ones ( n, 1 );

  for step = 1 : k
    
    for j = 1 : n
      in = find ( A(:,j) );
      a(j) = sum ( h(in) );
    end
    a = a / norm ( a, 2 );

    for i = 1 : n
      out = find ( A(i,:) );
      h(i) = sum ( a(out) );
    end
    h = h / norm ( h, 2 );

  end

  return
end
