reached(X) :- in_hm(Z,X), vertex(Z), vertex(X). in_hm(X,Y) | out_hm(X,Y) :- start(X), arc(X,Y). in_hm(X,Y) | out_hm(X,Y) :- reached(X), arc(X,Y). :- in_hm(X,Y), in_hm(X,Y1), Y != Y1, vertex(X), vertex(Y), vertex(Y1). :- in_hm(X,Y), in_hm(X1,Y), X != X1, vertex(X), vertex(Y), vertex(X1). :- arc(X,Z), not reached(X), vertex(Z), vertex(X). start(0).