CSE505/Assignment1/A/cycle.P
2024-02-22 23:50:15 -05:00

17 lines
373 B
OpenEdge ABL

:- include(randompath1000). % 2nd way of reading input facts
:- table path/2.
path(X,Y) :- edge(X,Y).
% Way 1
%path(X,Y) :- edge(X,Z), path(Z,Y).
% Way 2
path(X,Y) :- path(X,Z), edge(Z,Y).
% Way 3
%path(X,Y) :- path(X,Z), path(Z,Y).
cycle(X) :- path(X,X), !.
printPath :- path(X, Y), fail.
printPath.
timePath :- cputime(X), printPath, cputime(Y), T is Y-X, write(T).