function single_linkage_test ( )

%*****************************************************************************80
%
%% single_linkage_test() tests single_linkage().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    20 May 2016
%
%  Author:
%
%    John Burkardt
%
  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'single_linkage_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Test single_linkage()\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Demonstrate MATLAB functions for single linkage analysis\n' );
  fprintf ( 1, '  of sets of numeric data, in particular:\n' );
  fprintf ( 1, '  * sv = pdist ( xy ) computes the pairwise distance table\n' );
  fprintf ( 1, '    given a list of point coordinates.\n' );
  fprintf ( 1, '  * sl linkage ( sv, ''single'' ) computes the single\n' );
  fprintf ( 1, '    linkage information from the distance table.\n' );
  fprintf ( 1, '  * dendrogram ( sl ) displays the single linkage tree.\n' );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Test CANCELLED.\n' );
  fprintf ( 1, '  linkage() requires Statistics and Machine Learning Toolbox.\n' );
  return
%
%  Get a set of (X,Y) coordinates for 13 points from a text file.
%
  xy = load ( 'jb13_xy.txt' );
%
%  Compute the pairwise distance table from the positions.
%
  sv = pairwise_distance ( xy );
%
%  Compute the single linkage data from the distance table.
%
  sl = linkage ( sv, 'single' );
%
%  Plot the single linkage data.  
%  Label the data items with the given labels, rather than '1', '2', ...
%
  H = dendrogram ( sl, ...
    'Labels', {'A','B','C','D','E','F','G','H','I','J','K','L','M'}  );
%
%  Request that lines be drawn thicker than the default value of 1.
%
  set ( H, 'linewidth', 2 )
%
%  Save the plot.
%
  filename = 'single_linkage_test.png';
  print ( '-dpng', filename );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Plot saved as "%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'single_linkage_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  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

