View source with raw comments or as raw
    1% fact for each vertex(N).
    2vertex(a).
    3vertex(b).
    4vertex(c).
    5vertex(d).
    6
    7
    8% fact for each edge(U, V).
    9edge(b, a).
   10edge(b, d).
   11edge(a, c).
   12
   13edge(a, b).
   14edge(b, c).
   15edge(c, d).
   16edge(d, a).
   17
   18edge(c, a).
   19edge(a, d).
   20edge(d, b).
   21
   22
   23reachable(V) :- chosen(V, a).
   24reachable(V) :- chosen(V, U), reachable(U).
   25
   26
   27% Choose exactly one edge from each vertex.
   28chosen(U, V) :-
   29    edge(U, V), not other(U, V).
   30other(U, V) :-
   31    edge(U, V), not chosen(U, V).
   32
   33% Every vertex must be reachable.
   34:- vertex(U), not reachable(U).   35% You cannot choose two edges to the same vertex
   36:- chosen(U, W), U \= V, chosen(V, W).   37:- chosen(W, U), U \= V, chosen(W, V).   38
   39?- reachable(a).   40
   41#show chosen/2