SOCRATES : A graph about causality is one in which an object or objects moves or
move in terms of time respectively. Suppose a man eats chocolate. What are the steps in eating chocolate? What is the first step?
LUCIAN : Lift the piece of chocolate from the plate to your mouth.
SOCRATES : What is the second step?
LUCIAN : Chew and swallow it.
SOCRATES : What is the third step?
LUCIAN : Let it be pushed down your food pipe.
SOCRATES : What is the fourth step?
LUCIAN : Let your stomach digest it.
%% ?- find_links([[hand,1,2],[mouth,2,3],[food-pipe,3,4],[stomach,4,5]],1,5,List).
%% List = [hand, mouth, food-pipe, stomach]
%% find_links(Links,First,Last,List)
%% Links - List of [Item,Position1,Position2]
%% Item - e.g. hand, which moves between
%% positions 1 (Position1) and 2 (Position2)
%% First - first position
%% Last - last position
%% List - the list of positions in order
find_links(Links,First,Last,List) :-
find_links(Links,First,Last,[],List).
%% find_links(Links,First,Last,List1,List)
%% Links, First, Last, List are the same as for find_links/4
%% List1 - the current list of positions
find_links(_,Last,Last,List,List).
find_links(Links1,Curr,Last,List1,List2) :-
delete(Links1,[Item,Curr,Next],Links2),
append(List1,[Item],List3),
find_links(Links2,Next,Last,List3,List2).