function chain_letter_dendrogram ( )

%*****************************************************************************80
%
%% chain_letter_dendrogram makes a dendrogram from a distance matrix.
%
%  Discussion:
%
%    Students were given 11 chain letters.  Each student was asked to pick
%    a particular chain letter, and then estimate its "distance" from all
%    the chain letters, using a particular scoring system.  
%
%    The results are here assembled into a distance matrix, from which a
%    hierarchical clustering can be made and displayed.
%
%    The distances were based on comparing positions in thw chain letters where
%    a proper name occurred.
%
%    "New England"   0 if the same, 1 otherwise.
%    "R.A.F.Officer" 0 if the same, 1 otherwise.
%    "Gene Welch" 0 if the same, 1 if one name different, 2 if both different.
%    "Saul de Groda" 0 if the same, 1, 2 or 3 if 1, 2 or 3 names different or added.
%    "Constantine Dias" 0 if the same, 1 or 2 if 1 or 2 names different.
%    "Carlos Daddit" 0 if the same, 1 or 2 if 1 or 2 names different.
%    "Dalan Fairchild" 0 if the same, 1 or 2 if 1 or 2 names different.
%    "a young woman in California" 0 if both letters have or don't have this part, 
%      5 if one does and one doesn't.
%
%    The distance between the two chain letters is the sum of the 8 scores.
%
%    From the distance matrix, we can compute a dendrogram that suggests,
%    based on similarity, a sort of genealogy for the chain letters.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    02 May 2019
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'chain_letter_dendrogram:\n' );
  fprintf ( 1, '  MATLAB version\n' );
  fprintf ( 1, '  Construct a dendrogram to analyze the relationship\n' );
  fprintf ( 1, '  among a set of 11 versions of a chain letter.\n' );
%
%  Read the distance matrix from a file.
%
  filename = 'chain_letter_data.txt';
  data = load ( filename );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Chain letter distance matrix read from "%s"\n', filename );
%
%  Matlab's Statistical Toolbox can create a distance vector from a distance matrix,
%  then apply single linkage clustering to that to create a tree structure, and then
%  create a plot of the tree structure.
%
  dv = pdist ( data );
  dl = linkage ( dv, 'single' );
  H = dendrogram ( dl, ...
    'Labels', {'A','B','C','D','E','F','G','H','I','J','K'} );
%
%  Request that lines be drawn thicker than the default value of 1.
%
  set ( H, 'linewidth', 2 );

  title ( 'Dendrogram for 11 chain letters A=1 through K=11', 'Fontsize', 16 );

  filename = 'chain_letter_dendrogram.png';
  print ( '-dpng', filename );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'chain_letter_dendrogram:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  return
end
