function [ arcfir, fwdarc ] = digraph_arc_to_star ( L )

%*****************************************************************************80
%
%% digraph_arc_to_star() sets forward star representation of a digraph.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    18 April 2026
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer L(edge_num,2); the I-th edge
%    extends from node L(I,1) to L(I,2).
%
%  Output:
%
%    integer ARCFIR(node_num+1); ARCFIR(I) is the number of
%    the first edge starting at node I in the forward star representation.
%
%    integer FWDARC(edge_num); FWDARC(I) is the ending node of
%    the I-th edge in the forward star representation.
%
  edge_num = size ( L, 1 );
  node_num = max ( max ( L ) );
%
%  Set up the forward star representation.
%
  arcfir = zeros ( node_num + 1, 1 );
  fwdarc = zeros ( edge_num, 1 );

  k = 0;

  for i = 1 : node_num

    arcfir(i) = k + 1;

    for j = 1 : edge_num

      if ( L(j,1) == i )
        k = k + 1;
        fwdarc(k) = L(j,2);
      end

    end

  end

  arcfir(node_num+1) = k + 1;

  return
end
