function neighbor_risk_test ( )

%*****************************************************************************80
%
%% neighbor_risk_test() tests neighbor_risk().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    03 November 2022
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../neighbor_risk' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'neighbor_risk_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s:\n', version ( ) );
  fprintf ( 1, '  neighbor_risk() records connections between territories\n' );
  fprintf ( 1, '  in the game of RISK.\n' );
  fprintf ( 1, '  Plot a web of these connections as a graph.\n' );
%
%  Retrieve the adjacency matrix.
%
  A = risk_adjacency_matrix ( );

  n = size ( A, 1 );
%
%  List pairs (s,t) of connected territories.
%
  nz = nnz ( A ) / 2;
  s = zeros ( nz, 1 );
  t = zeros ( nz, 1 );

  k = 0;
  for i = 1 : n
    for j = i + 1 : n
      if ( A(i,j) == 1 )
        k = k + 1;
        s(k) = i;
        t(k) = j;
      end
    end
  end 
%
%  Create a graph from S and T.
%
  G = graph ( s, t );
%
%  Set up node labels as the two-letter state abbreviations.
%
  labels = risk_label ( );
%
%  Plot the graph
%
  plot ( G, ...
    'Layout', 'auto', ...
    'NodeLabel', labels, ...
    'LineWidth', 2, ...
    'MarkerSize', 10 );

  title ( 'RISK Neighbors', 'Fontsize', 16 );
%
%  Save a copy.
%
  filename = 'neighbor_risk.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'neighbor_risk_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  timestamp ( )

  rmpath ( '../neighbor_risk' );

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the current YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 February 2003
%
%  Author:
%
%    John Burkardt
%
  t = now;
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

