function value = graph_adj_is_tree ( A )

%*****************************************************************************80
%
%% graph_adj_is_tree() determines whether a graph is a tree.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    15 March 2023
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer A(node_num,node_num): the adjacency matrix.
%
%  Output:
%
%    logical value: true if the graph is a tree.
%
  node_num = size ( A, 1 );

  if ( node_num <= 1 )
    value = true;
    return
  end
%
%  Every node must be connected to every other node.
%
  connected = graph_adj_is_nodewise_connected_depth ( A );

  if ( ~ connected )
    value = false;
    return
  end
%
%  There must be exactly node_num-1 edges.
%
  edge_num = graph_adj_edge_count ( A );

  value = ( edge_num == node_num - 1 );

  return
end
