CSE505/A/cycle.P

9 lines
123 B
Plaintext
Raw Normal View History

2024-02-19 23:38:00 -05:00
edge(1,2).
edge(2,1).
edge(1,3).
path(X,Y) :- edge(X,Y).
path(X,Y) :- edge(X,Z), path(Z,Y), !.
cycle(X) :- path(X,X), !.