%% Prolog
%% A Tutorial Introduction
%% James Lu
%% Jerud J. Mead
%% Computer Science Department
%% EasingintoProlog.


edge(a,b).
edge(a,f).
edge(f,g).
edge(f,c).
edge(f,e).
edge(g,c).
edge(b,c).
edge(c,e).
edge(c,d).
edge(e,d).
edge(d,a).

path(Node1,Node2) :-
	edge(Node1,Node2).

path(Node1,Node2) :-
	edge(Node1,SomeNode),
	path(SomeNode,Node2).

chain(X,Y,[]).

chain(X,Y,[X,Y]) :-
	edge(X,Y).

chain(X,Y,[X|Z]) :-
	edge(X,I),
	path(I,Y),
	chain(I,Y,Z).












