function grf_write ( output_filename, node_num, edge_num, edge_pointer, ...
  edge_data, xy )

%*****************************************************************************80
%
%% grf_write() writes a GRF file.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    13 January 2009
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    string OUTPUT_FILENAME, the name of the file
%    to which the data should be written.
%
%    integer NODE_NUM, the number of nodes.
%
%    integer EDGE_NUM, the number of edges.
%
%    integer EDGE_POINTER(NODE_NUM+1), pointers to the
%    first edge item for each node.
%
%    integer EDGE_DATA(EDGE_NUM), indices of adjacent nodes.
%
%    real XY(2,NODE_NUM), the node coordinates.
%

%
%  Open the file.
%
  output_unit = fopen ( output_filename, 'wt' );

  if ( output_unit < 0 ) 
    fprintf ( 1, '\n' );
    fprintf ( 1, 'grf_write(): Fatal error!\n' );
    fprintf ( 1, '  Could not open the output file "%s".\n', output_filename );
    error ( 'grf_write(): Fatal error!' );
  end
%
%  Write the header.
%
  if ( false )
    grf_header_write ( output_filename, output_unit, node_num, edge_num );
  end
%
%  Write the data.
%
  grf_data_write ( output_unit, node_num, edge_num, edge_pointer, ...
    edge_data, xy )
%
%  Close the file.
%
  fclose ( output_unit );

  return
end
