function treepack_test13 ( )

%*****************************************************************************80
%
%% TREEPACK_TEST13 tests TREE_RB_LEX_NEXT, TREE_RB_TO_PARENT.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    28 June 2013
%
%  Author:
%
%    John Burkardt
%
  n = 11;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'TREEPACK_TEST13\n' );
  fprintf ( 1, '  TREE_RB_LEX_NEXT produces all rooted binary trees with\n' );
  fprintf ( 1, '  a given number of nodes, in lexicographic order,\n' );
  fprintf ( 1, '  using the preorder traversal representation.\n' );
  fprintf ( 1, '  TREE_RB_TO_PARENT converts the preorder traversal form\n' );
  fprintf ( 1, '  to the more comprehensible parent node representation.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  The number of nodes N = %d\n', n );
  fprintf ( 1, '\n' );

  more = 0;
  i = 0;
  a = [];

  while ( 1 )

    [ a, more ] = tree_rb_lex_next ( n, a, more );

    if ( ~ more ) 
      break
    end

    parent = tree_rb_to_parent ( n, a );

    i = i + 1;
    fprintf ( 1, '  %2d  ', i );
    for j = 1 : n
      fprintf ( 1, '%3d', parent(j) );
    end
    fprintf ( 1, '\n' );

  end

  return
end

