% nacteni:
/* ['3.4_13.pl']. */

solution(Node,Solution) :- depth_first_search([], Node,Solution).

depth_first_search(Path,Node,[Node|Path]) :- goal(Node).
depth_first_search(Path,Node,Sol) :- move(Node,Node1),
    \+ member(Node1,Path),depth_first_search([Node|Path],Node1,Sol).

% vzorova data
goal(e).
move(a,b). move(a,e). move(a,f).
move(b,c). move(f,c). move(c,d). move(d,e).

% demonstracni vypis

start:- 
    write('depth_first_search'),nl,
    write('Prvni reseni solution(a,Solution):'),nl,
    solution(a,Solution),write(Solution),nl.
?-start.

