% Iterative Deepening

edge(a, b).
edge(a, c).
edge(a, d).
edge(b, e).
edge(b, f).
edge(d, g).
edge(d, h).
edge(f, i).
edge(f, j).
edge(j, k).
edge(j, l).
edge(a, f).

is_path(N1, N2) :-

    is_path(N1, N2, 0).

is_path(N1, N2, Iterator) :-
    Iterator < 100,
    is_connected(N1, N2, 0, Iterator).


is_path(N1, N2, Iterator) :-
    Iterator < 100,
    IteratorNeu is Iterator + 1,
    is_path(N1, N2, IteratorNeu).


is_connected(N1, N2, Akt, Max) :-
    Akt < Max, edge(N1, N2).

is_connected(N1, N2, Akt, Max) :-
    Akt < Max, edge(N1, N),
    AktNeu is Akt + 1,
    is_connected(N, N2, AktNeu, Max).