function graph_dist_one_test ( )

%*****************************************************************************80
%
%% graph_dist_one_test() tests graph_dist_one().
%
%  Discussion:
%
%    This example appears on page 15 of the reference book by Gibbons.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    06 November 2024
%
%  Author:
%
%    John Burkardt
%
  nnode = 5;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'graph_dist_one_test():\n' );
  fprintf ( 1, '  graph_dist_one() computes the distance from one\n' );
  fprintf ( 1, '  node to all others in a graph.\n' );
  fprintf ( 1, '\n' );
 
  for i = 1 : nnode
    for j = 1 : nnode
      dist(i,j) = Inf;
    end
    dist(i,i) = 0.0;
  end
 
  dist(1,2) = 1.0;
  dist(1,3) = 3.0;
 
  dist(2,1) = 2.0;
  dist(2,3) = 1.0;
  dist(2,5) = 2.0;
 
  dist(3,4) = 2.0;
  dist(3,5) = 3.0;
 
  dist(4,3) = 1.0;
 
  dist(5,1) = 1.0;
  dist(5,2) = 3.0;
  dist(5,4) = 6.0;

  graph_dist_print ( dist, nnode, '  Edge Distance Matrix:' );

  inode = 5;
  fprintf ( 1, '\n' );
  fprintf ( 1, 'The starting node is %d\n', inode );
  fprintf ( 1, '\n' );

  [ path_dist, idad, path ] = graph_dist_one ( dist, inode, nnode );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Node    Distance   Path Idad\n' );
  fprintf ( 1, '\n' );
 
  for i = 1 : nnode
    fprintf ( 1, '%5d %14.6g %5d %5d\n', i, path_dist(i), path(i), idad(i) );
  end
 
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Here are the paths for each node:\n' );
  fprintf ( 1, '\n' );
 
  for i = 1 : nnode

    length = 1;
    itemp(length) = i;
 
    while ( itemp(length) ~= inode )
      length = length + 1;
      itemp(length) = idad(itemp(length-1));
    end
 
    for j = 1 : length
      fprintf ( 1, '  %5d', itemp(j) );
    end
    fprintf ( 1, '\n' );
 
  end
 
  return
end
