Итеративно търсене по нива (Iterative deepening)
iterative_deepening(Stack,Goal,Path) :-
findall(arc(X,Y,Z),arc(X,Y,Z),Graph), length(Graph,N), iterative_deepening1(1,Stack,Goal,Path,N).
iterative_deepening1(Depth,Stack,Goal,Path,Max) :-
depth_bound(Depth, Stack,Goal,Path).
iterative_deepening1(Depth,Stack,Goal,Path,Max) :-
Depth1 is Depth+1, Depth =< Max,!, iterative_deepening1(Depth1,Stack,Goal,Path,Max).