how can i find all path of node that are connected between : a to g by using rules on Prolog ?
The graph

my simple code:
cites(a,c).
cites(a,c).
cites(b,d).
cites(b,e).
cites(c,f).
cites(e,g).
cites(f,g).
cites(g,d).
cites(h,g).
connected(A,B):-cites(A ,B).
connected(A,B):-cites(A ,C),connected(C ,B).
The first thing you need is a way to generate or test routes. I would do that like this. It will successively find all possible routes via backtracking:
Once you have that, then it's a simple matter of using
findall/3,bagof/3orsetof/3to collect all solutions in a list of lists. Something like: