Guest User

Untitled

a guest
Jan 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.52 KB | None | 0 0
  1. % Question 2
  2.  
  3. child(a, b).
  4. child(a, c).
  5. child(b, d).
  6. child(b, e).
  7. child(c, f).
  8. child(c, g).
  9.  
  10. move([Node|State],[NextNode|State]):-
  11.     child(Node,NextNode),
  12.     \+ member(NextNode,[Node|State]).
  13.  
  14. goal(Node):- \+ child(Node,_).
  15.  
  16. visited_df(N,List):-
  17.     solve_depthfirst([N],Path),
  18.     last(Path,[List]).
  19.  
  20. depthfirst_traversal(N,List):-
  21.     findall(X,visited_df(N,X),List).
  22.  
  23. visited_bf(N,List):-
  24.     solve_breadthfirst([N],Path),
  25.     last(Path,[List]).
  26.  
  27. breadthfirst_traversal(N,List):-
  28.     findall(X,visited_bf(N,X),List).
Add Comment
Please, Sign In to add comment