function W = graph_adj_walks ( A )

%*****************************************************************************80
%
%% graph_adj_walks() counts the walks between any pair of nodes.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    25 February 2023
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer A(n,n): the adjacency matrix for the graph.
%
%  Output:
%
%    integer W(n,n): the number of walks between each pair of nodes.
%
  value = matrix_is_adjacency ( A );

  if ( ~ value )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'graph_adj_walks(): Fatal error!\n' );
    fprintf ( 1, '  The input is not a legal adjacency matrix.\n' );  
    error ( 'graph_adj_walks(): Fatal error!\n' );
  end

  n = size ( A, 1 );

  Ak = eye ( n, n );
  W = Ak;

  for k = 1 : n - 1
    Ak = Ak * A;
    W = W + Ak;
  end

  return
end

