function edge_num = graph_adj_edge_count ( adj )

%*****************************************************************************80
%
%% graph_adj_edge_count() counts the edges in a graph.
%
%  Discussion:
%
%    Self-edges are allowed.
%
%    The adjacency matrix is assumed to be symmetric, so all edges
%    except self-edges will appear twice.
%
%    The resulting sum must count the self-edges double, and then divide
%    the number of edges counted by 2.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    11 March 2023
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer adj(node_num,node_num), the adjacency information.
%
%  Output:
%
%    integer edge_num: the number of edges in the graph.
%
  edge_num = sum ( sum ( adj ) ) + sum ( diag ( adj ) );

  edge_num = edge_num / 2;

  return
end
