2.3.2.3. Graph generators
This section describes how to generate the initial graph associated with a global constraint. Initial graphs correspond to directed hypergraphs [Berge87], which have a very regular structure. They are defined in the following way:
The vertices of the directed hypergraph are generated from collections of items such that each item corresponds to one vertex of the directed hypergraph. These collections are either collections that arise as arguments of the global constraint, or collections that are derived from one or several arguments of the global constraint. In this latter case these derived collections are computed by using the collection generators previously introduced (see Section 2.3.2.1 on page 2.3.2.1).
To all arcs of the directed hypergraph corresponds the same arc constraint that involves vertices in a given order.Usually the edges of a hypergraph are not oriented [Berge87]. However for our purpose we need to define an order on the vertices of an edge since the corresponding arc constraint takes its arguments in a given order. These arc constraints, which are mainly unary and binary constraints, were described in the previous section (see Section 2.3.2.2 on page 2.3.2.2). We describe all the arcs of an initial graph with a set of predefined arc generators, which correspond to classical regular structures one can find in the graph literature [Skiena90]. An arc generator of arity takes collections of items, denoted , as input and returns the corresponding hypergraph where the vertices are the items of the input collections and where all arcs involve vertices. Specific arc generators allow for giving an -ary constraint for which is not fixed, which means that the corresponding hypergraph contains arcs involving various number of vertices.
Each arc generator has a name and takes one or several collections of items as input and generates a set of arcs. Each arc is made from a sequence of items and is denoted by . is called the arity of the arc generator. We have the following types of arc generators:
Arc generators with a fixed predefined arity. In fact most arc generators have a fixed predefined arity of 2. The graphs they generate correspond to digraphs.
Arc generators that can be used with any arity greater than or equal to 1. These arc generators generate directed hypergraphs where all arcs consist of items.
Arc generators that generate arcs that do not involve the same number of items.
We now give the list of arc generators, listed in alphabetic order, and the arcs they generate. For each arc generator we point to a global constraint where it is used in practice. Finally, Figure 2.3.4 illustrates the different arc generators. At present the following arc generators are in use:
has a predefined arity of 2. It takes one collection and generates the following arcsAs defined in Section 2.2.2 on page 2.2.2 we use the following notation: for a given collection , and respectively denote the number of items of and the item of .:
: ,
: .
has a predefined arity of 2. It takes one collection and generates the following arcs:
: ,
.
can be used with any arity greater than or equal to 2. It takes one collection and generates the arcs: .
, where is one of the comparison operators , , , , , , can be used with any arity greater than or equal to 2. It takes one collection and generates the arcs:
such that
such that .
has a predefined arity of 2. It takes one collection and generates the following arcs:
and ,
and .
takes a collection consisting of items and generates the arcs where and satisfy the following condition. There exists an integer such that (1) and (2) hold:
(when we have ),
.
has a predefined arity of 2. It takes one collection and generates the arcs: : . is usually used in order to generate a loop on some vertices, so that they do not disappear from the final graph.
can be used with any arity greater than or equal to 1. It takes one collection , and generates the following arcs: .
generates arcs that do not involve the same number of items. It takes one collection , and generates the following arcs: .
generates arcs that do not involve the same number of items. It takes one collection , and generates the following arcs: .
has a predefined arity of 2. It takes two collections , and generates the arcs: .
, where is one of the comparison operators , , , , , , has a predefined arity of 2. It takes two collections , and generates the arcs: such that .
has a predefined arity of 1. It takes one collection and generates the arcs: : .
has a predefined arity of 2. It takes two collections , and generates the following arcs: and .
, where is one of the comparison operators , , , , , , has a predefined arity of 2. It takes two collections , and generates the arcs: such that and .
takes one collection and does not generate any arc.
Finally, we can combine the arc generator with the arc generators from the following set , , , , , . This is achieved by using the construction where and belong to . It applies to the first collection passed to and to the second collection passed to . Finally, it applies on and . In a similar way the arc generator is extended to .
EXAMPLE: As an illustrative example, consider the constraint, which uses the arc generator on the collections and . It generates the following arcs:
Since the first argument of is it generates an arc between each pair of items of the collection.
Since the second argument of is it generates a loop for each item of the collection.
Since the third argument is the comparison operator it finally generates an arc between an item of the collection and an item of the collection when the two items have the same position.
Figure 2.3.3 shows the generated graph under the hypothesis that and have respectively 3 and 3 items.
Figure 2.3.3. Example of initial graph generated by when applied to collections and
Figure 2.3.4 illustrates the different arc generators. On the one hand, for those arc generators that take a single collection, we apply them on the collection of items . On the other hand, for those arc generators that take two collections, we apply them on and . We use the following pictogram for the graphical representation of a constraint network:
A line for an arc constraint of arity 1,
An arrow for an arc constraint of arity 2,
A closed line for an arc constraint with an arity strictly greater than 2. In this last case, since the vertices of an arc are ordered, a black circle at one of the extremities indicates the direction of the closed line. For instance consider the example of in Figure 2.3.4. The closed line that contains vertices 1, 2 and 3 means that a 3-ary arc constraint involves items 1, 2, and 3 in this specific order.
Dotted circles represent vertices that do not belong to the graph. This stems from the fact that the arc generator did not produce any arc involving these vertices. The leftmost lowest corner indicates the arity of the corresponding arc generator:
An integer if it has a fixed predefined arity,
if it can be used with any arity greater than or equal to 1,
if it generates arcs that do not necessarily involve the same number of items.