%% this is surely the simplest possible depth first search :- ensure_loaded(showPath). dfs :- dfs(Path), showPath(Path). dfs(Path) :- start(S), dfs(S,Path). dfs(S,[S]) :- goal(S). dfs(S,[S|Rest]) :- arc(S,S2), dfs(S2,Rest).