Re: More on Aggregation Predicates



This gives me [a] as the result, but what i am trying is to get the
list of nodes between two nodes say on giving x,y it shld give 'a' as
the result.As both x and y are connected through 'a' .

If i give x and z it should return [a,b] as the result.I tried like
findall(X, links(x,y), S). no result is shown.

Can anyone help me to get this , i googled up more but no result so
far.

I have two programs that may help.

This one finds more than one path between two nodes. "Arc" is the list
of facts that connect one node to another. To find a node, enter
path(a,b) or whatever path you are trying to find
/*****************************************
:- dynamic found/1.

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

legal(Z,[]).
legal(Z,[H|T]):- Z \= H, legal(Z,T).

path_worker(X,Y,Visited):- arc(X,Y),\+found(Y),assert(found(Y)).
path_worker(X,Y,Visited):-
arc(X,Z),legal(Z,Visited),path_worker(Z,Y,[Z|Visited]).

path(X,Y):- path_worker(X,Y,[X]).

/*****************************************

If this one doesn't work, look here for more examples:

http://sc0g.com/college/CS310

.