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

  1. #include "graph.h"
  2.  
  3. /*            BREADTH_GRAPH_
  4.  
  5.     The constructor passes the start node, goal node and the number of
  6.     operators to SEARCH_.
  7.  
  8. */
  9.  
  10. BREADTH_GRAPH_::BREADTH_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 BREADTH_GRAPH_::add(NODE_ *succ)
  25. {
  26.     if (!closed.lookup(*succ) && !open.lookup(*succ))
  27. // if successor is neither on closed nor open add it to the TAIL of open
  28.     {
  29.         open.addtotail(*succ);
  30.         return(1);
  31.     }
  32.     return(0);
  33. }
  34.