Attachment 'hamiltonian-path.core.asp.txt'
Download 1 % guess the path
2 path(X,Y) v outPath(X,Y) :- edge(X,Y), reached(X).
3 :- start(X), path(_,X).
4
5 % each vertex in the path must have at most one
6 % incoming and one outcoming edge
7 :- vtx(X), path(X,Y), path(X,Z), Y != Z.
8 :- vtx(X), path(X1,X), path(X2,X), X1 != X2.
9
10 % the path must feature all vertices
11 :- vtx(X), not reached(X).
12 reached(X) :- path(Y,X).
13 reached(X) :- start(X).
Attached Files
You are not allowed to attach a file to this page.