[ library(gfd) | Reference Manual | Alphabetic Index ]
# <ConsistencyModule:> ham_path(?Start,?End,+Succ)

Constrains elements in Succ to form a Hamiltonian path from Start to End.
*Start*
- An integer or (domain) variable (array notation accepted)
*End*
- An integer or (domain) variable (array notation accepted)
*Succ*
- A collection of different (domain) variables or integers

## Description

Succ is a collection of N elements presenting a digraph of N nodes, where
the i'th element of Succ represents the successor to node i. The constraint
enforces Succ to form a Hamiltonian path, a path through every node in
the graph, visiting each node once, with Start giving the first node
of the path, and End giving the last node of the path. Note that the
Succ of the last node will be N+1, i.e. a dummy node not in the graph.

Note that the Gecode implementation of this constraint has index (node id)
starting from 0, rather than 1. This constraint is actually posted
as ham_path_offset_g/3 with an offset of 1. A version of this constraint
with native Gecode indexing is available as circuit_g/1.

ConsistencyModule is the optional module specification to give the
consistency level for the propagation for this constraint:
gfd_gac for generalised arc consistency (domain consistency),
and gfd_vc for value consistency.

This constraint is implemented by Gecode's path() constraint, using an offset
of 1.

## Examples

[eclipse 5]: ham_path(S,E,[X]).
S = 1
E = 1
X = 2
[eclipse 2]: ham_path(S,E,[A,B]).
S = S{[1, 2]}
E = E{[1, 2]}
A = A{[2, 3]}
B = B{[1, 3]}
[eclipse 3]: ham_path(2,1,[A,B]).
A = 3
B = 1
[eclipse 5]: ham_path(S,E,[2,4,1]).
S = 3
E = 2

## See Also

ham_path_g / 3, ham_path_offset_g / 4