function perm_tj_successor_test ( )

%*****************************************************************************80
%
%% PERM_TJ_SUCCESSOR_TEST tests PERM_TJ_SUCCESSOR.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    23 December 2015
%
%  Author:
%
%    John Burkardt
%
  n = 4;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'PERM_TJ_SUCCESSOR_TEST\n' );
  fprintf ( 1, '  PERM_TJ_SUCCESSOR lists\n' );
  fprintf ( 1, '  permutations using the Trotter-Johnson ordering,\n' );

  p = [];
  rank = -1;

  while ( 1 )

    rank_old = rank;

    [ p, rank ] = perm_tj_successor ( n, p, rank );

    if ( rank <= rank_old )
      break
    end

    fprintf ( 1, '%4d:', rank );
    for i = 1 : n
      fprintf ( 1, '%5d', p(i) );
    end
    fprintf ( 1, '\n' );

  end

  return
end
