about a prolog breadth-first exercises



hello, this is my exercises about a prolog breadth-first, i fill the
places, but it doesn't work, anybody can help me?
thanks.




[Exercises]Fill out places blank:

/*define successors first*/
successor(s,a).
successor(s,b).
successor(a,s).
successor(a,b).
successor(a,c).
successor(b,s).
successor(b,a).
successor(b,g).
successor(c,a).
successor(c,g).
successor(g,b).
successor(g,c).

/*define goal state*/
goalnode(g).

/*breadth first sarch*/
breadthfirst(Startnode,Solution_path) :-
bdsearch([Startnode],Solution_path).
bdsearch([Node|Path|_],[Node|Path]) :- goalnode(Node).
bdsearch([Node|Path],Solution_path) :-
expand(________,________), %expand the leftmost node
append(________,________,New_paths), %add the children node to list
bdsearch(New_paths,Solution_path). %call bdsearch recursively
%define predicate expand
expand([Node|Path],New_paths):- bagof([X,Node|Path],
(successor(____,___),not(member(___,[Node|Path]))),New_paths),!.
expand(_,[]).




[My Answers]

/*breadth first sarch*/
breadthfirst(Startnode,Solution_path) :-
bdsearch([Startnode],Solution_path).

bdsearch([Node|Path|_],[Node|Path]) :- goalnode(Node).
bdsearch([Node|Path],Solution_path) :-
expand(Node,New_paths), %expand the leftmost node
append(Path,New_paths,New_paths), %add the children node to list
bdsearch(New_paths,Solution_path). %call bdsearch recursively


%define predicate expand
expand([Node|Path],New_paths):- bagof([X,Node|Path],
(successor(Node,X),not(member(X,[Node|Path]))),New_paths),!.
expand(_,[]).

.