function a = sudoku_adj ( )

%*****************************************************************************80
%
%% SUDOKU_ADJ returns the Sudoku adjacency matrix.
%
%  Discussion:
%
%    A Sudoko is a 9x9 array, subdivided into 9 3x3 blocks.
%
%    Two elements of the 9x9 array are adjacent if they lie in the same
%    row, column, or 3x3 subblock.
%
%    The eigenvalues of the Sudoku adjacency matrix are all integers.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    19 February 2018
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Output, real A(81,81), the matrix.
%
  a = zeros ( 81, 81 );

  for i = 1 : 81
    rowi = 1 + floor ( ( i - 1 ) / 9 );
    coli = 1 + mod ( i - 1, 9 );
    browi = 1 + floor ( ( rowi - 1 ) / 3 );
    bcoli = 1 + floor ( ( coli - 1 ) / 3 );
    for j = 1 : 81
      rowj = 1 + floor ( ( j - 1 ) / 9 );
      colj = 1 + mod ( j - 1, 9 );
      browj = 1 + floor ( ( rowj - 1 ) / 3 );
      bcolj = 1 + floor ( ( colj - 1 ) / 3 );
      if ( rowi == rowj || ... 
           coli == colj || ...
           ( browi == browj && bcoli == bcolj ) )
        a(i,j) = 1;
      end
    end
  end

  return
end
