Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Question 2
- child(a, b).
- child(a, c).
- child(b, d).
- child(b, e).
- child(c, f).
- child(c, g).
- move([Node|State],[NextNode|State]):-
- child(Node,NextNode),
- \+ member(NextNode,[Node|State]).
- goal(Node):- \+ child(Node,_).
- visited_df(N,List):-
- solve_depthfirst([N],Path),
- last(Path,[List]).
- depthfirst_traversal(N,List):-
- findall(X,visited_df(N,X),List).
- visited_bf(N,List):-
- solve_breadthfirst([N],Path),
- last(Path,[List]).
- breadthfirst_traversal(N,List):-
- findall(X,visited_bf(N,X),List).
Add Comment
Please, Sign In to add comment