function L = graph_adj_list_to_arc ( AP, AL )

%*****************************************************************************80
%
%% graph_adj_list_to_arc() converts an adjacency list to an arc list.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    28 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 L(edge_num,2): the arc list.
%
  edge_num = length ( AL );
  node_num = length ( AP ) - 1;

  L = zeros ( edge_num, 2 );

  edge_num = 0;
  for node_i = 1 : node_num
    for k = AP(node_i) : AP(node_i+1) - 1
      edge_num = edge_num + 1;
      node_j = AL(edge_num);
      L(edge_num,1) = node_i;
      L(edge_num,2) = node_j;
    end
  end
  
  return
end

