dfs([Node | OPEN], _ , Goal) :-
Node==Goal, !,
write('yes! goal reached.... ' - Goal), nl.
dfs([Node | OPEN],CLOSED, Goal) :-
findall( Next,
(
arc(Node, Next), Next
not(member(Next, OPEN)), not(member(Next, CLOSED))
),
NewNode
),
append(NewNode, OPEN, NewOPEN),
write('OPEN = frontier of search...'), write(NewOPEN),nl,
write('CLOSED = nodes already visited...'), write([Node | CLOSED]),nl,nl,
dfs(NewOPEN, [Node | CLOSED], Goal). % recurse with new data
弧(a,b)。弧(a,c)。弧(b,d)。弧(b,e)。弧(c,f)。弧(f,g)。弧(e,z)。弧(d,e)。弧(z,g)。弧(z,d)。