%----------------------------------------------------------- % Inefficient breadth-first search (nearly identical to depth-first search) %----------------------------------------------------------- breadth_first_search_slow(Arc,Start,GoalPred,Sol):- bfs_slow(Arc,[[Start]],[],GoalPred,Sol). bfs_slow(_,[[Node|Path]|_],_,GoalPred,[Node|Path]):- call(GoalPred,Node). bfs_slow(Arc,[[Node|Path]|MoreOPEN],CLOSED,GoalPred,Sol):- findall([Next,Node|Path], (call(Arc,Node,Next), not(member([Next|_],[[Node|Path]|MoreOPEN])), not(member(Next,CLOSED))), NewPaths), % place the new paths on the bottom of the queue append(MoreOPEN,NewPaths,NewOPEN), %closing(Node), bfs_slow(Arc,NewOPEN,[Node|CLOSED],GoalPred,Sol).