function components_3d_test ( )

%*****************************************************************************80
%
%% components_3d_test() tests components_3d().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    17 July 2022
%
%  Author:
%
%    John Burkardt
%
  l = 64;
  m = 64;
  n = 26;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'components_3d_test():\n' );
  fprintf ( 1, '  components_3d() finds and labels connected\n' );
  fprintf ( 1, '  components in a 3D integer block.\n' );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  A is a 3D block of order %d*%d*%d\n', l, m, n );

  A = zeros ( l, m, n );
%
%  Retrieve the indices of nonzero data in A by reading a file.
%
  ijk = load ( 'indices.txt' );
%
%  You might try to guess how to work with 3D arrays from how 2D
%  arrays work.  But it didn't work out for me.  So I give up, and
%  will do the stoopid things instead.
%
  [ m1, n1 ] = size ( ijk );
  for l1 = 1 : m1
    A(ijk(l1,1),ijk(l1,2),ijk(l1,3)) = 1;
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Number of nonzero A values is %d\n', sum ( sum ( sum ( A ) ) ) );
%
%  Determine the components.
%
  C = components_3d ( A );
  component_num = max ( max ( max ( C ) ) );

  s = zeros ( 1, component_num );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Number of components = %d\n', component_num );

  for i = 1 : l
    for j = 1 : m
      for k = 1 : n
        if ( C(i,j,k) ~= 0 )
          s(C(i,j,k)) = s(C(i,j,k)) + 1;
        end
      end
    end
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Component  Size\n' );
  fprintf ( 1, '\n' );
  for i = 1 : component_num
    fprintf ( 1, '  %4d  %8d\n', i, s(i) );
  end
  fprintf ( 1, '------  --------\n' );
  fprintf ( 1, ' Total  %8d\n', sum ( s(1:component_num) ) );

  return
end
