function power_graph ( n, a )

%*****************************************************************************80
%
%% POWER_GRAPH uses the power method to seek an eigenvector of a directed graph.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    04 September 2015
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer N, the number of nodes.
%
%    Input, integer A(N,N), the adjacency matrix.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'POWER_GRAPH:\n' );
  fprintf ( 1, '  Given an NxN adjacency matrix A,\n' );
  fprintf ( 1, '  compute the transition matrix T,\n' );
  fprintf ( 1, '  Then start with a vector of N values 1/N,\n' );
  fprintf ( 1, '  and repeatedly compute x <= T*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' );
%
%  Compute the transition matrix.
%
  t = adj_to_transit ( n, a );
%
%  Set the starting vector.
%
  x = ones ( n, 1 ) / n;
%
%  Carry out many iterations.
%  Normalization is not necessary because T is a transition matrix.
%
  for i = 1 : 100

    x = t * x;

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

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

  return
end
