function value = matrix_is_adjacency ( A )

%*****************************************************************************80
%
%% matrix_is_adjacency() checks whether a matrix is an adjacency matrix.
%
%  Discussion:
%
%    This function requires that:
%      A is square;
%      A is symmetric;
%      A has a zero diagonal.
%      A only involves entries of 0 or 1.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    07 March 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real A(M,N), the matrix.
%
%  Output:
%
%    logical VALUE: TRUE if A is an adjacency matrix.
%
  [ m, n ] = size ( A );
  if ( m ~= n )
    value = false;
    return
  end

  if ( any ( any ( A ~= transpose ( A ) ) ) )
    value = false;
    return
  end

  d = diag ( A );
  not0 = find ( d ~= 0 );
  if ( 0 < length ( not0 ) )
    value = false;
    return
  end

  not01 = find ( A ~= 0 & A ~= 1 );
  if ( 0 < length ( not01 ) )
    value = false;
    return
  end

  value = true;

  return
end

