a(g,h).
a(g,d).
a(d,a).
a(e,d).
a(h,f).
a(h,f).
a(a,e).
a(e,f).
a(a,b).
a(b,f).

pathCic(X,Y):- pathC(X,Y,[]).

pathC(X,X,L).
pathC(X,Y,L):- a(X,Z), notvisited(Z,L), pathC(Z,Y,[Z|L]).

notvisited(Z,[]).
notvisited(Z,[X|Y]):- X\==Z, notvisited(Z,Y).
