home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / GRAPH.ZIP / AI / SRC / UNISEAR / GDEPTH.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-12  |  650 b   |  34 lines

  1. #include "graph.h"
  2.  
  3. /*                      DEPTH_GRAPH_
  4.  
  5.     The constructor passes the start node, goal node and the number of
  6.     operators to SEARCH_.
  7.  
  8. */
  9.  
  10. DEPTH_GRAPH_::DEPTH_GRAPH_(NODE_ *start, NODE_ *goal, int op)
  11.     :SEARCH_(start, goal, op)
  12. {
  13. }
  14.  
  15.  
  16.  
  17. /*                      ADD
  18.  
  19.     Adds a node to the search graph, only if it's not already in the
  20.     graph.
  21.  
  22. */
  23.  
  24. int DEPTH_GRAPH_::add(NODE_ *succ)
  25. {
  26.     if (!closed.lookup(*succ) && !open.lookup(*succ))
  27. // if successors is neither on open nor closed add it to the HEAD of open
  28.     {
  29.         open.addtohead(*succ);
  30.         return(1);
  31.     }
  32.     return(0);
  33. }
  34.