[ library(cycle) | Reference Manual | Alphabetic Index ]

# cycle(+Edges, ++EdgeWeights, -CycleCost)

A constraint that forces a Hamiltonian cycle in a directed graph

Edges
  A list of ic variables
EdgeWeights
  A square matrix of integers
CycleCost
  The cost of the cycle

## Description

    	Edges is a list of length VertexCount of ic variables, where VertexCount is the number of
    	vertices in the graph. Each variable needs to have a domain which is the subset of
    	[1..VertexCount]. The values in the i-th variable's domain correspond to edges in the
    	graph, so the domain value j of the i-th variable corresponds to an edge (i,j).

    	EdgeWeights is a square matrix (array of arrays) of size VertexCount*VertexCount of nonnegative
    	integers. The value indexed [i,j] corresponds to the cost of the edge (i,j). Values on the diagonal
    	([i,i]) are unimportant since the correspond to edges (i,i) which are automatically removed by
    	the constraint.

    	CycleCost is an ic variable that corresponds to the cost of the cycle.

    	This version of the constraint uses the maximal propagation level. For more details and
    	configuration of different propagation levels see cycle/4.

### Modes and Determinism

- cycle(+, ++, -) is semidet

### Fail Conditions

It is impossible to find any Hamiltonian cycle in the graph

### Exceptions

(1) general error
  Wrong edge weigh matrix size.
(1) general error
  Wrong edge list length.
(6) out of range
  Wrong edge domain values.
(1) general error
  Wrong weight value.
(8) bad argument list
  Unknown options

## See Also

cycle / 4