  fprintf ( 1, '\n' );
  fprintf ( 1, 'DFS_STACK_TEST:\n' );
  fprintf ( 1, '  Use the DFS_STACK function to carry out a\n' );
  fprintf ( 1, '  depth-first search of a graph, with a stack.\n' );
%
%  N is the number of nodes.
%
  n = 18;
%
%  FIRST is the node where we want to begin.
%
 first = 17;
%
%  ADJ_POINTER(I) indicates where the list of all neighbors of
%  node I begins, and ADJ_POINTER(I+1)-1 is where that list ends.
%
  adj_pointer = [ ...
    1,  2,  4,  5,  6, 9, 10, 12, 15, 18, ...
   19, 22, 24, 26, 28, 30, 32, 34, 35 ]';
%
%  ADJ() contains the neighbors of all the nodes, listed in a
%  single list.
%
%  In MATLAB, we could have used a cell array to handle this
%  in a simpler manner.
%
  adj = [ ...
  7, ...
  3,  8, ...
  2, ...
  5, ...
  4,  6, 11, ...
  5, ...
  1, 13, ...
  2,  9, 14, ...
  8, 10, 15, ...
  9, ...
  5, 12, 17, ...
 11, 18, ...
  7, 14, ...
  8, 13, ...
  9, 16, ...
 15, 17, ...
 11, 16, ...
 12, ]';
%
%  LABEL contains a one-character label for each node.
%
  label = [ ...
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', ...
    'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R' ]';

  first = 17;
  n = 18;

  dfs_stack ( n, first, adj_pointer, adj, label );

