function A = graph_adj_list_to_adj ( AP, AL )

%*****************************************************************************80
%
%% graph_adj_list_to_adj() converts an adjacency list to an adjacency matrix.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    27 April 2026
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer AP(node_num+1): the index of the first edge for each node.
%
%    integer AL(edge_num): the list of ending nodes for each edge.
%
%  Output:
%
%    integer A(node_num,node_num), the adjacency matrix.
%
  node_num = length ( AP ) - 1;
  edge_num = length ( AL );

  A = zeros ( node_num, node_num );

  for node_i = 1 : node_num
    for edge = AP(node_i) : AP(node_i+1) - 1
      node_j = AL(edge);
      A(node_i,node_j) = 1;
    end
  end

  return
end

