Propagation Rules for Graph Partitioning Constraints

We review existing methods and present a generic propagation mechanism for graph partitioning constraints based on directed matchings. The task is also to give a set of several propagation rules according to speciﬁc partition properties. Every solution of the global constraint corresponds to a subgraph of the corresponding digraph associated with the constraint. The ﬁltering identiﬁes the arcs of the digraph that do not belong to a so-lution. We illustrate this principle on some common global constraints


Introduction
Graphs are often used to model different various computational problems.A number of combinatorial problems rely on the partitioning of a graph into a set of components.The usual graph partitioning problem comprises of dividing a graph into smaller subgraphs with specific properties, such that the subgraphs are isomorphic and each vertex of the graph belongs to exactly one of these components.Important applications of graph partitioning problems include many areas of mathematics and computer science.
Typically, graph partitioning problems fall under the category of intractable problems.Even for special graph classes it can be shown that no reasonable fully polynomial algorithms exist for these graphs.Solutions to these problems are generally derived using heuristics and approximation algorithms.One competitive approach to solving such problems is constraint programming (CP).The main motivation for this work is to expand the results of constraint programming to graph partitioning problems by proposing more effective filtering algorithm for the graph partitioning constraints.
Recently, the graph partitioning problem was gained importance due to its application in constraint programming.Some works about global constraints and constraint programming have appeared in the journals of operations research [31], [47], [61], [16].In papers [15,17] filtering algorithms were introduced that use the semantic of the constraint in terms of maximum matching.In this paper, we extend this concept to global constraints representable by directed graphs.We present a paradigm based on a directed matching.We illustrate our method with a complete study of specific global constraints.
Constraints that describe partitions of the vertices in a given initial graph have been considered from an early stage of constraint programming research.Some examples include the proper forest [8], tour [17], clique [23], [51] (modeled using undirected graphs), circuit [38], [37], cycle [5], tree [6], [22], path [9] (modeled as directed graphs), and cost tour [16], shorter path [55], weighted spanning tree [52], [53] (modeled by weighted graphs) constraints.Most of the problems involving these constraints are intractable in general.This work goes one step further by introducing a set of specific propagation rules for global constraints on directed graphs.
The paper provides a new constraint programming technique to solve graph partitioning problems on digraphs.It is based on a combination of a new method to decompose a digraph into subgraphs by exploiting strongly connected components and dominators, and algorithms for solving the maximum matching problem.In principle this gives a somehow generic method to filter these global constraints.
This work describes a unified approach to propagating graph partitioning constraints such as circuit, cycle, derangement (and its soft version), tree, binary tree, path and map.Our goal is to show that a solution to one of them can be used to solve them all.The method is based on the reduction of some digraph matching problem (called directed matching) to the maximum matching problem on a bipartite graph.Decomposition theory for bipartite graphs is then used to come up with specific algorithms for filtering the arcs of the respective digraph representing the partition.
The approach consists of two steps.First, a solution representing a given partition in a digraph is constructed.This can be done by using a directed matching and any standard algorithm for finding a matching in a bipartite graph.Next, a set of allowed, forbidden and mandatory arcs is determined.The results provide a general algorithm for solving any graph partitioning problem.In all these situations the problem of interest can be formulated as the matching problem defined over the appropriate bipartite graph.
We want to point out that our goal is not to partition a given digraph D associated with a global constraint, but rather to find out whether it is possible to make and detect those arcs of D that do not belong to any partition corresponding to a specific pattern.
This paper is organized as follows.In Section 2 we first present the necessary formal background on constraint programming and graph theory.Section 3 deals with an algorithmic method based on the decomposition theory of directed graphs.We present an alternative way of computing strongly connected components in a directed graph, suited for our technique detailed later.Section 4 is the central part of the paper.A general tool is first presented (based on matching theory) which is then used to give new filtering algorithms for several graph partitioning constraints.The studied problems are formulated as a matching problem on a suitable bipartite graph associated with the input digraph corresponding to the constraint.In this section examples are given and filtering algorithms are developed.We demonstrate how decomposition theory applies to such problems.We also describe a well-known decomposition method which uses the strong components of D and present a more powerful decomposition method based on the dominators of D. Finally, in Section 5 we review related results, discuss future work and conclude.
The following tables summarize all the theoretical results for graph partitioning constraints we will deal with in this paper.The first table gives an overview of complexities.Here n denotes the number of vertices and m is the number of edges.The second table gives an exhaustive list of the basic properties for all graph partitioning constraints discussed in this paper.

Preliminaries
We start with formal definitions of the central concepts.We first recall some necessary terminology of the theory of digraphs, matching theory and constraint programming that we will use in the rest of the paper.We assume that the reader is familiar with the essentials of complexity theory (for a review, see [25], [39,Chapter 3] or [14,Chapter 34]).

Theory of Digraphs
We use standard terminology but for the sake of clarity we repeat the most important definitions and notations from [28]: A digraph (directed graph) D is a pair (V, E), where V is a finite set of elements, called vertices (or nodes), and E ⊆ V × V is a set of ordered pairs (v i , v j ) of vertices, called arcs (or directed edges).The number of vertices n = |V | is the order of D. The number of arcs m = |E| is the size of D.
A digraph H is a subdigraph of D if V (H) ⊆ V (D) and E(H) ⊆ E(D).If V (H) = V (D), then H is called a spanning subdigraph (or a factor ) of D.
If (v i , v j ) is an arc of D, then v i is called the head (or initial endpoint) and v j is called the tail (or terminal endpoint).Graphically, the vertices can be represented by points, and (v i , v j ) will be represented by an arrow connecting the points v i and v j , v j being at the tip of the arrow.
An arc whose endpoints coincide is called a loop.Two arcs, or edges, are called adjacent if they have at least one endpoint in common.We consider graphs without multiple (parallel) edges but which may contain loops.
Vertex u is called a successor of vertex v if there is an arc with v as its initial endpoint and u as its terminal endpoint.The set of all successors of v is denoted by Similarly, vertex u is called a predecessor of vertex v if there exists an arc of the form (u, v).The set of all predecessors of vertex v is denoted by

JGAA, 20(2) 363-410 (2016) 367
The set of all neighbors of v is denoted by For a set X ⊆ V , we let The outward degree (or out-degree for short) of a vertex v in D, denoted by d + (v), is the number of arcs starting at (leaving) v and the inward degree (or in-degree for short) of a vertex v, denoted by d − (v), is the number of arcs terminating at (entering) v.The total degree (or just degree) of a vertex v, denoted by d(v), is defined by Clearly, we have: It is easy to see that the sum of in-degrees of all vertices equals the sum of out-degrees of all vertices and both are equal to the number of arcs in the digraph: the vertex v is said to be an isolated node; if d + (v) = 0 and d − (v) = 0, the vertex v is called a source; if d + (v) = 0 and d − (v) = 0, the vertex v is called a sink.We use subscripts (e.g.d + D (v)) to specify the digraph D if the usage is not clear from the context.
A directed path P of length k is a sequence of k+1 distinct vertices v 0 , v 1 , . . ., v k together with the k distinct arcs (v 0 , v 1 ), (v 1 , v 2 ), . . ., (v k−1 , v k ).The vertex v 0 is the initial endpoint (or source) of the path P , the vertex v k is the terminal endpoint (or target) of the path P , and the remaining vertices are the internal nodes of the path P .A directed circuit is a (directed) path that begins and ends at the same vertex.
A digraph is called strongly connected (or strong) if, for any two vertices v i and v j , there exists a path from v i to v j and a path from v j to v i .Finding the strong components in a directed graph has a variety of applications.Tarjan was the first to obtain an elegant linear time algorithm with complexity O(m + n) to compute the strong components of a digraph [58].His algorithm utilizes depth first search in a clever way.Tarjan's algorithm, its complexity and correctness, is presented in the textbook [14].
A strong component of a digraph D is a maximal strongly connected subdigraph of D. We assume that the trivial digraph, consisting of exactly one vertex is vacuously strong since it does not contain two distinct vertices.Corresponding to any digraph D, there is a new digraph whose definition is based on the strong components of D. Let S 1 , S 2 , . . ., S p be the strong components of a digraph D. The strong component graph (also called the condensation) of D, is the simple digraph SC(D) with vertex set V (SC(D)) = {s 1 , s 2 , . . ., s p }, such that there is an arc in digraph SC(D) from vertex s i to vertex s j if and only if there is an arc in digraph D from a vertex in strong component S i to a vertex in strong component S j .Multiple arcs from a given strongly connected component to another strongly connected component are merged.
Notice that the strong component graph of any digraph (some authors use the term reduced digraph to describe such digraphs) is a directed acyclic graph, that is, it contains no directed cycles.Note that at this point we allow acyclic digraphs to contain loops.An acyclic digraph is often referred to by its abbreviation, DAG.The term DAG is typically pronounced as a word, not spelled out as an acronym.
A topological ordering of a directed graph D is a total order ≺ on the nodes such that u ≺ v for every arc (u, v).Less formally, a topological ordering arranges the nodes horizontally or vertically so that all arcs point from one item to the next.A topological ordering is not possible if the digraph D has a cycle, since for two nodes v and w on the cycle, both v ≺ w and w ≺ v. Furthermore, the topological ordering is not necessarily unique.Any DAG has at least one topological ordering, which can be found in linear time [14,Section 22.4].
Acyclic digraphs play a very important role in both theory and applications of digraphs and form a well-studied family of digraphs, in particular, due to the following important properties: • In every directed acyclic graph there is at least one source (a vertex with no incoming edges: d − (v) = 0) as well as at least one sink (a vertex of out-degree zero: d + (v) = 0).
• Every acyclic digraph has a topological ordering of its vertices.
• For every vertex v there is a source s such that there is a path from s to v, and there is a sink t such that there is a path from v to t.
Clearly, in any digraph all the vertices on a cycle belong to the same strongly connected component.A strongly connected component will be called a source component if it corresponds to a source vertex in a strong component graph.Analogously, a strongly connected component of D that corresponds to a sink of SC(D) is called a sink component.A strongly connected component is trivial if it consists of one vertex without a loop, and is non-trivial otherwise.
In order to obtain short proofs of various results on subdigraphs or efficiently solve many problems dealing with directed graphs the following transformation of a directed graph D to a bipartite graph is extremely useful [28, page 411].
Let D be a directed graph of order n and size m.Associated with D is a bipartite graph BR(D) with two color classes V 1 = {v 1 , . . ., v n } and V 2 = {v 1 , . . ., v n }.The elements of V 1 are called outward, and the elements of V 2 are JGAA, 20(2) 363-410 (2016) 369 called inward.A pair {v i , v j } is an edge of BR(D) if there exists an arc of the form (v i , v j ) in D. We call BR(D) the bipartite representation of D.
The augmented bipartite graph corresponding to the directed graph D is graph BR * (D) defined as the graph with the same vertex sets V 1 and V 2 as BR(D).Every edge of BR(D) is an edge of BR * (D) and in addition the n unordered pairs {v i , v i }, i = 1, 2, . . ., n are edges of BR * (D).

Matching Theory
Recall that a matching in an undirected graph G = (V, E) is a set of edges from E, no two of which share a vertex, a maximum matching of G is a matching of maximal cardinality among all matchings of G and a perfect matching is a set of pairwise disjoint edges that cover all the vertices of G.For arbitrary graphs finding a maximum matching fast is quite complicated and it was a great breakthrough when Edmonds [20] found a polynomial algorithm.For both bipartite and general graphs the perfect matching problem is solvable in time O( √ n • m) [33], [46].The notion of a matching is sometimes too restrictive and so we define a more general concept, a degree-matching.A degree-matching is a set of edges M where, for each vertex x of the graph, we restrict the number of edges of M incident with x to be within a given interval.More formally, let g and f be integer-valued functions, called degree conditions, such that 0 ≤ g(x) ≤ f (x) ≤ d(x).A perfect f -matching is a degree-matching such that the number of edges belonging to M incident with vertex x equals f (x).Analogously, a perfect (g, f )matching is a degree-matching such that the number of matched edges incident with x has to be between g(x) and f (x).Naturally, if g(x) = 0 and f (x) = 1 for every vertex x then a degree-matching becomes a standard matching.Note that a perfect 2-matching is a collection of vertex-disjoint cycles, and an acyclic (1,2)-matching is a collection of vertex-disjoint paths.
An elementary graph is a graph such that the union of perfect matchings forms a connected spanning subgraph.An elementary bipartite graph is a graph in which every edge is contained in some perfect matching.The similar definitions can be given for graphs with degree-matchings.
Let D = (V, E) be a digraph with vertex set V (D) and arc set E(D).Further, let g = (g − , g + ) and f = (f − , f + ) be pairs of non-negative integervalued functions defined on We say that the digraph D has a directed perfect f -matching if there exists a spanning subdigraph The existence of a directed perfect matching in a digraph is equivalent to the existence of a perfect matching in its corresponding bipartite representation.For given pairs of functions g = (g − , g + ) and f = (f − , f + ) defined on V (D), we define two functions g, f : Then it is easy to see that D has a directed perfect f -matching if and only if BR(D) has a perfect f -matching, and that D has a directed perfect ( g, f )matching if and only if BR(D) has a perfect (g, f )-matching.
The following necessary and sufficient conditions for the existence of a directed perfect ( g, f )-matching are easily verified using matching theory (for bipartite graphs).
for all X ⊆ V .
Proof: The proof of this theorem is analogous as for Theorem 2.4.5 in [44].
A cycle cover of an undirected graph is a spanning subgraph that consists solely of single cycles in which every vertex is a part of exactly one cycle.Cycle covers are also known as 2-factors since every vertex has degree two in a cycle cover.
A cycle factor in a directed graph D = (V, E) is a spanning subdigraph of D in which the inward and outward degree of every vertex v is equal to 1: Observe that a strongly connected digraph needs not necessarily have a cycle factor.We can use matching theory to find a cycle factor in a given digraph or to prove that none exists.We now begin with the necessary and sufficient condition for the existence of a cycle factor in a digraph.for each X ⊆ V .This looks, in fact, very much like a translation of Hall's Theorem [30] into the language of directed graphs.Indeed, it is practically the same result.It can be proven by applying the Hall's Theorem to a bipartite representation BR(D) constructed from digraph D. It is easy to see that D has a cycle factor if and only if the bipartite graph BR(D) contains a perfect matching.
A path factor of a digraph D is a spanning subdigraph, each of whose components is a path.Note that a directed matching does not exclude cycles, whereas a path factor is acyclic.It is obvious that if a digraph has a cycle factor, then it also has a path factor.The converse is not true.

Constraint Programming
We will assume that the reader is familiar with the basic results of constraint programming, which we briefly review now and state some useful terminology to make the notation clear.For a thorough explanation of this area we refer the reader to the monographs [2], [18] and [62].
A domain variable x is a variable ranging over a finite set of integers denoted by D x .The minimum and maximum values of D x are denoted by min(D x ) and max(D x ), respectively.
A constraint network (CN) consists of a set {x 1 , . . ., x n } of variables, a set {D x1 , . . ., D xn } of domains which represent the set of possible values that each variable can take, and a set of constraints C ⊆ D x1 × . . .× D xn which link up the variables and define the set of combination of values that are allowed.The search for an instantiation of all variables that satisfy all the constraints is called a Constraint Satisfaction Problem (CSP), and such an instantiation is called a solution to a CSP.
A filtering algorithm for the constraint satisfaction problem removes values from domains that do not participate in a solution to it.A propagation algorithm helps to identify and detect values that cannot be taken by the variables of the constraints in any solution of the problem.
The pruning is a task which shrinks the domain of each variable without changing the set of solutions.We say that the pruning is incomplete if it removes some inconsistent values but not every inconsistent value.A pruning is complete if the removal of any additional value from any domain would change the set of solutions.
Many constraints that appear in modeling, and for which specialized domain reduction propagation algorithms have been developed, are called global constraints.Very often a global constraint can be modeled by a graph and a solution can be represented as some type of a degree-matching problem.Several examples are given of encodings of global constraints where values (or rather assignments) in the constraints correspond to edges (see, for example, [19], [15,17]).Moreover, it is shown that one can generalize the techniques used in standard matching to find out which edges belong to all degree-matchings, some degreematchings or no degree-matching.With respect to a specified degree-matching such edges will be, respectively, called mandatory, allowed or forbidden.
Classification of the edges is performed by applying the so-called alternating depth-first search on the graph G associated with the global constraint.The fundamental tool used in this method is the Dulmage-Mendelsohn (DM) and Gallai-Edmonds (GE) Decomposition, which are canonical decompositions of bipartite and general graphs based on the notion of matching.We need to traverse the edges of the graph with respect to an initial matching.An alternating depth-first search simulates the traversing on a directed graph and constructs layers that alternately use matched and free edges.Clearly, an alternating depth-first search maintains alternating cycles (for more details, see [15]).The algorithm can also be used to maintain the strongly connected components.
Analogously to the classical depth-first search the alternating depth-first search induces two numberings of the vertices of the traversed graph G, one in the order in which the vertices are reached by a search and one in the order in which the vertex exploration is completed.The two numbers associated with the vertex are usually called its discovery and finishing time number.The core of a strongly connected component is the vertex with the smallest discovery number.
Throughout this paper we will use the convention that in figures the solid lines indicate the edges of the graph, the thick solid lines denote matched edges and the dashed lines shown the forbidden edges.The edges marked by crosses x are forbidden, as well.The degree conditions of every vertex are shown in the brackets near the vertex in the auxiliary bipartite graph.

Canonical Decomposition
In this section we consider the canonical decomposition of directed graphs with respect to strong connectivity.As a consequence, we give a new linear time algorithm for the detection of strongly connected components in a directed graph.We will see that the strong components of a directed graph become the elementary subgraphs of an associated bipartite graph.The results presented in this section are mainly based on the joint work of Johnson, Dulmage and Mendelsohn [35].
Pruning consists of classifying the arcs of the digraph into three mutually exclusive sets: forbidden arcs -those arcs which cannot be in any strongly connected component, mandatory arcs -those arcs which are required and must be in any strongly connected component, and the remaining, allowed arcs -those arcs which may be in some strongly connected component, but its removal has no effect on the component.Proof: See Theorem 4 in [35].
The last property gives us immediately a simple filtering algorithm with respect to the constraint strongly connected [4].A brute force approach with complexity of O(m 2 ) has been described in [19].A filtering algorithm according to a strong connectivity looks as follows.First, we create graph BR * (D).Next, we start with an initial empty matching and iterate over i = 1, . . ., n.We add to the initial matching the edge {v i , v i }.Then, the application of the alternating depth-first search to the initial matching M results in hyper-arc consistency with respect to the strongly connected constraint (Figure 1).Let us explain our approach in some technical detail.A filtering algorithm for strong connectivity can be derived from properties of a perfect matching.It is based on the fact that an arc (i, j) belongs to a strongly connected component if the corresponding edge {i , j } is part of some perfect matching.
Consider the example in Figure 1.The problem is modeled as follows.On the left side of the figure a directed graph D in which we want to find strongly connected components is depicted.On the right side of the figure the augmented bipartite graph BR * (D) is presented.The bold edges in the graph denote an initial perfect matching.
The alternating depth-first search applied to this problem instance decomposes the graph into two elementary bipartite graphs.According to their properties the edge connecting two distinct elementary bipartite graphs are forbidden.Thus, since the edges {1 , 4 } and {2 , 4 } are forbidden in BR * (D), the corresponding arcs (x 1 , x 4 ) and (x 2 , x 4 ) don't belong to any strongly connected component of D. Proof: See Theorem 6 in [35].
Observe that our filtering routine which is used simultaneously with the method to find all strongly connected components does not detect mandatory arcs.Such arcs that are necessary for the strong connectivity of the digraph are called strong bridges.The strong bridges can be detected in linear time [34].
It is well-known (see, for example, Theorem 4 in [15]) that elementary subgraphs of a bipartite graph G = (V 1 ∪ V 2 , E) with a perfect matching can be labeled in such a way that every edge in G from a subgraph G i to a subgraph G j with i < j has one endpoint in V 2 and the other one in V 1 .This property applies to the augmented bipartite graph BR * (D).In other words, the elementary subgraphs of BR * (D) encode the strongly connected components of the digraph D and moreover induce a topological ordering of the strong component graph SC(D).
We now prove the theorem, which guarantees that the alternating depthfirst search can be also used on BR * (D) in order to determine the topological ordering of SC(D).
Theorem 5 Let S i and S j be two strongly connected components of a directed graph D. If there is an arc (u, v) such that u ∈ S i and v ∈ S j , then the core of S i will have a higher finishing time than the core of S j and be sorted first.
Proof: There are two cases to consider.If alternating depth-first search visits any node in S i before S j , then clearly all of S i and S j will be explored before alternating depth-first search terminates.Therefore, the core of the strongly connected component S i (the first node visited in S i ) will have a larger finishing time than any other node in S j .On the other hand, if S j is explored first, then alternating depth-first search will terminate after visiting all nodes of S j but before visiting any node in S i , in which case the property also holds.
According to this theorem, a node with the largest finishing time must be in a source component.However, note that the theorem does not imply that a node with the smallest finishing time must be in a sink component.As a counterexample consider a digraph given by V The algorithm looks as follows.All steps can be performed in linear time.Perform an alternating depth-first search starting from some vertex of V (see Algorithm 2 in [15]) Find the partition of mandatory (strong bridges), allowed and forbidden arcs Let the number of strongly connected components be the number of core vertices in the depth-first forest For every strongly connected component of D determine its topological ordering number Although decomposition using strong components is efficient and useful in practice, many graph partitioning problems have one or only a few strong com-ponents.Therefore, in the subsequent section of this paper we develop a more powerful decomposition technique based on dominators.

Graph Partitioning Constraints
In this section we present a graph-theoretic analysis of a directed matching, using matching theory.We show a direct reduction of the directed matching problem on a digraph to the maximum matching problem on a bigraph.This reduction yields an algorithm to determine the partition of edges in the directed matching making use of decomposition theory for bipartite graphs.In this section examples are given and filtering algorithms are developed.
In order to investigate global constraints we first introduce the digraph associated with any instance of these constraints1 .Let X = {x 1 , x 2 , . . ., x n } be a set of n variables with respective finite domains D xi ⊆ {1, 2, . . ., n} for i = 1, 2, . . ., n.To these variables we can associate the digraph Observe that the number of vertices is equal to the number of variables, and the number of arcs equals the sum of domain cardinalities.Thus, Hence, a directed edge (v i , v j ) exists if and only if j is in the domain of variable x i .Moreover, elimination of an arc (v i , v j ) from the associated digraph during the pruning means removing of the value j from the domain of x i .
A digraph associated with a global constraint can be viewed as an undirected graph by forgetting the orientation of its arcs, removing loops and merging all multiple resulting edges.We call this graph the underlying graph associated with the global constraint.Clearly, elimination of an edge {v i , v j } from the underlying graph during the pruning is equivalent both to the removing of the value j from the domain of variable x i (if it exists) and the removing of the value i from the domain of variable x j (if it exists).
Our algorithm to find a partition of edges is based on the following simple observation.
Theorem 6 Let D be a digraph associated with the global constraint and assume that there exists a one-to-one correspondence between the solution of the constraint and the directed perfect ( g, f )-matching in D. Further, let BR(D) denotes the bipartite representation of D. Then, the necessary condition to satisfiability of the constraint is that BR(D) must have a perfect (g, f )-matching.Moreover, the mandatory (or forbidden) edges in a perfect (g, f )-matching of BR(D) are mandatory (or forbidden) arcs in a directed perfect ( g, f )-matching of the digraph D.
Proof: Suppose that BR(D) has a perfect (g, f )-matching M consisting of the edges e 1 , . . ., e |M | .Then the arcs form a directed perfect ( g, f )-matching.Indeed, in the subdigraph D induced by these arcs every vertex v i has an outdegree and an in-degree equal to the number of matched edges incident to x i on the outward side and to y i on the inward side of BR(D), respectively, and, according to the definition, such a subdigraph is precisely a directed perfect ( g, f )-matching in D.
To illustrate this theorem, consider Figure 2.
In order to obtain the desired partition of edges we need only to apply an alternating depth-first search on BR(D) with respect to M (for more details, see [15,Section 4]).The alternating depth-first forest (computed by the algorithm devised in [15]) is shown on the right side of the figure.Since edge {1 , 3} in BR(D) is forbidden and edge {3, 4 } is mandatory, arc (3, 1) in D is forbidden (drawn as a dashed arrow), and arc (3,4)

is mandatory (drawn as a bold arrow).
A graph partitioning constraint can be seen as a problem for finding a partial graph of a given digraph associated with the constraint.Graph partitioning constraints are the main subject of the thesis written by Lorca [42].From an interpretation point of view the subdigraphs so obtained are called functional graphs and they have the characteristic property that the out-degree of each vertex is equal to 1 (i.e.every vertex of the partition has exactly one successor).Thus, we will always have g

for all vertices on the outward side of the corresponding bipartite graph BR(D).
The graph partitioning constraint can be formally defined as follows.The constraint can be written

pattern(npattern, nodes)
where npattern is a count variable specifying the number of components in the graph partition, and nodes is a collection of n variables {x 1 , . . ., x n }, whose domains consist of elements of {1, . . ., n}, i.e.D xi ⊆ {1, . . ., n} for each i.An associated directed graph D contains an arc (x i , x j ) if and only if j belongs to the domain of x i .An arc (x i , x j ) of D is selected when x i = j and the constraint enforces that the selected arcs form a satisfactory partition.
The constraint partitions a given associated digraph D described by the nodes collection into a set of vertex-disjoint components.The constraint requires that in the digraph D there are exactly npattern components, such that every vertex of D belongs to exactly one component.The constraint holds if the associated digraph D is covered by a set npattern functional graphs in such a way that each vertex of D belongs to one distinct component (to a single component).
By the continuity property for the count variable of a graph partitioning constraint we mean that if a digraph associated with the constraint can be decomposed into r and s connected components, where r ≤ s, then it can be decomposed into k components for all k such that r ≤ k ≤ s.
In the following we will demonstrate the reduction technique on some graph partitioning constraints.The method is composed of two main phases.The first one focuses on checking if a constraint has a solution.The second phase makes it possible to find some arcs that do not participate in any solution.This phase can be split into three steps: bounds filtering of count variable(s), pruning forbidden arcs when the count variable is instantiated to one of its extrema, and structural filtering.The bounds filtering concentrates on the cardinality of the expected partition.It consists of removing the values of count variable that are out of range.The structural filtering detects the arcs that do not belong to the expected partition and reduces the domain variables of constraint.All steps are complementary and together form a (partial) filtering for a graph partitioning constraint.
It is now time to demonstrate our idea on concrete examples.For every global constraint we first give its formal definition and some applications, then we derive a transformation to the matching problem, and finally we discuss some related problems.All definitions are taken from the Global Constraint Catalog [4].
Some of the examples are illustrated by figures.On the left side of the figure the domains of the variables are given.In the middle of the figure, digraph associated with the global constraint and its corresponding bipartite representation are depicted and the partition of edges is highlighted.The thick edges indicate a matching, while the vertical dashed lines show forbidden edges.On the right side of the figure the reduced domains after pruning are presented.

The CIRCUIT constraint
The circuit constraint was first formulated by Laurière [38].It can be viewed as describing a Hamiltonian circuit 2 on a directed graph D associated with the constraint.The constraint is defined as circuit(nodes), where nodes is a collection of variables {x 1 , . . ., x n } whose domains are subsets of {1, . . ., n}.It requires that a tuple (d 1 , . . ., d n ) be a cyclic permutation of (1, . . ., n), where each d i+1 = x di and x dn = d 1 .
For the global constraint circuit there is a very immediate reduction from the Hamiltonian circuit, which demonstrates that reasoning with this constraint is generally intractable.For this reason, it is perhaps not surprising that, in the past, there has been little comment on it.Therefore, we now formally prove its computational intractability.A famous combinatorial problem that can be modeled with the circuit constraint is the Traveling Salesperson Problem (abbreviated as TSP) [39].Many other problems can be expressed in terms of Hamiltonian cycles, such as the Euler Knight's Tour Problem on a chessboard, or the Chinese Postman Problem [44,Section 6.5].
Clearly, checking a circuit constraint for satisfiability is equivalent to checking if an associated digraph has a Hamiltonian circuit, which is an NP-complete problem [36].There exist, however, several necessary conditions that can be verified in polynomial time.
An obvious necessary condition for a digraph to be Hamiltonian is that the graph must be strongly connected.However, this condition is not sufficient.Another obvious and quite powerful necessary condition for a digraph to be Hamiltonian is the existence of a cycle factor.Clearly, a Hamiltonian circuit is a cycle factor but the converse is not necessarily true because some cycle factors may consist of several disjoint circuits.
We know that achieving hyper-arc consistency for circuit is NP-hard.Therefore, we will now describe some useful incomplete filtering methods, that run in polynomial time, which are only partially related to those presented in [12], [37] and [57].
One of the elementary filtering methods for circuit is based on the alldifferent constraint [49].The alldifferent filtering method can be applied because all the variables of the nodes collection have to take distinct values.A further necessary condition to satisfiability of this constraint is to have at most one single strongly connected component.
The filter removes inconsistent values by eliminating non-Hamiltonian arcs from the associated digraph, that is, arcs that belong to no Hamiltonian circuit.Filtering can also be based on sufficient conditions for non-Hamiltonicity of a digraph, some of which appear in [39,Chapter 11].Most of the known sufficient conditions for a digraph D to be Hamiltonian assert that if the degrees of the vertices of D are sufficiently large [3], [45], [64], or D has enough arcs [41], then D is Hamiltonian.Unfortunately, the number of arcs must be nearly as large as the number of edges in a complete graph with n vertices.
We have taken care of many sufficient conditions for a digraph to have a Hamiltonian circuit.However, none of these are necessary conditions.For example, the oriented cycle C n , the simplest Hamiltonian digraph of all, does not satisfy any of these conditions when n is large.
Kaya and Hooker presented in [37] a recursive algorithm that eliminates non-Hamiltonian arcs from the graph via vertex separators.Their filter is based on an idea put forward by Chvátal that every Hamiltonian graph is 1-tough 3 (for details, see [39, page 405]).Their algorithm identifies almost all unsatisfiable instances and eliminates about one-third of the inconsistent values from the variable domains.The authors give a filtering algorithm for the circuit constraint but its description in the book by Hooker [32] contains some flaws which can be confusing.For example, the filtering based on the alldifferent constraint will remove the dashed arcs from the sample graphs depicted in Figure 3.15, contrary to the claim stated for two examples that the both situations are independent.
In fact, the alldiff filtering seems to be stronger than the vertex-degree filtering described in [32,Section 3.11.2].Indeed, alldifferent requires all variables to take distinct values.It corresponds to a cycle factor, since the variables and their domains represent the same set of elements.Therefore, to resolve the problem we state it in the terms of a directed matching.
Suppose that S separates D into p connected components denoted by C = {C 1 , . . ., C p }.The digraph D S induced by the separator S is defined as follows.The node set of D S is V (D S ) = S ∪ C. The arc set E(D S ) is obtained by the following rules: D S contains an arc e if e ∈ E(D), as well as an arc (v, w) whenever (v, c i ) and (c j , w) are arcs of D for some pair of nodes c i and c j in C k ∈ C (possibly c i = c j , or c i and c j need not be joined by an arc).
We set then the degree conditions as follows: in a directed perfect (g, f )matching, but we give a construction which guarantees that the incoming and outgoing degree of each node in the directed matching M is the same.To this end, we attach f + (x) − 1 loops for every x ∈ C.This guarantees that the number of ingoing and outgoing arcs in every directed perfect matching will be identical, i.e. d − F (x) = d + F (x) for every directed f -factor F .The following theorem classifies arcs of a digraph as non-Hamiltonian by looking for a certain kind of a directed degree-matching in a much smaller digraph.Proof: The proof of this theorem is an easy consequence of Theorem 1, Corollary 1 and Corollary 2 of [37] adapted for directed graphs.
According to this theorem a vertex separator induces a strongly connected digraph and a much smaller partial digraph is constructed from a vertex separator of the original graph.Then, by applying a filtering algorithm for the alldifferent constraint, a cycle factor of a subdigraph is found, so that the forbidden arcs can be identified and eliminated from the digraph.The construction guarantees that every cycle factor of D S will have at least one incoming and at least one outgoing arc joining S with each connected component C k .
We now demonstrate a partial filtering method which explicitly uses the properties of the Gallai-Edmonds Canonical Decomposition and the results presented in [17,Theorem 9].Our idea is based on identifying a perfect 2-matching in the underlying graph associated with the constraint.This follows from the fact that every Hamiltonian circuit is a 2-factor and each 2-factor can be considered as a generalization of a Hamiltonian circuit.Our routine looks for a perfect 2-matching in the underlying graph and the corresponding edge not belonging to it will be removed from the associated digraph (together with an opposite arc, if it exists).This will result in deleting some 2-cycles from the associated digraph, which cannot be a part of any Hamiltonian circuit.Note that the problem of removing all cycles of length two from the Hamiltonian digraph is NP-hard [25,Problem GT13].However, our method coupled with the alldifferent constraint gives a more effective pruning.
Observe that neither filtering method is redundant of the other, but both combined together improve the propagation behavior in some cases, as can be seen in the following example.Let circuit(x 1 , . . ., x 8 ) constraint have the following domains A stronger propagation mechanism can also be implemented if we observe that circuit corresponds to a connection relationship.We can thus discard situations where it is impossible to build a strongly connected pattern.Pruning for imposing this condition can be done by choosing all strong bridges to belong to the solution, since otherwise the strongly connected component would be broken down.Computing the forbidden arcs can be then done in linear time, since the strong bridges can be computed in linear time [34].
We give a summary of our algorithm: where p denotes the number of maximal extreme sets in the underlying graph.
Pruning according to the Dulmage-Mendelsohn Canonical Decomposition can be realized in linear time [15].The complexity of the procedure for each separator |S| is approximately O(|S| 5 ) [37].
The last four steps of the algorithm must be repeated until no more arcs are pruned.Our experiments indicate that the directed matching connected with the method based on the Gallai-Edmonds decomposition of the underlying graph provides a better filtering.Additionally, approach DM + GE requires a smaller number of iterations than GE + DM .
In our implementation, we have set the step of computing the strong components immediately after the pruning with respect to a directed matching (alldifferent constraint), since strong connectivity in a given strongly connected digraph can be broken by removing the forbidden arcs.

The CYCLE constraint
The cycle is a useful constraint that was introduced in CHIP [5] in order to tackle hard combinatorial problems.The constraint specifies the number of cycles that must cover a directed graph.It can be used for modeling various problems such as the multiple traveling salesmen problem [39, pages 23-25 and 169-170], the vehicle routing problem [39, Chapter 12], [5], and the balanced Euler knight problem [11].A thesis dealing with the cycle constraint is written by Bourreau [11].
The constraint has the form cycle(ncycle, nodes), where ncycle is a domain variable and nodes is a collection {x 1 , . . ., x n } of domain variables with D xi ⊆ {1, . . ., n} for each i.
The cycle constraint partitions a given associated digraph described by the nodes collection into a set of vertex-disjoint cycles.The constraint requires that in the digraph there are exactly ncycle directed circuits, such that every vertex belongs to exactly one cycle.
As the first interpretation, the cycle(ncycle, nodes) constraint can be seen as the problem of finding ncycle distinct cycles in a directed graph in such a way that each vertex is visited exactly once.In the second interpretation, this constraint can be considered as the number of ncycle cycles of a permutation x 1 , . . ., x n .
Both observations are equivalent to the formulation of the alldifferent constraint.This can be seen from the fact that a cycle in a directed graph D is a spanning subdigraph of D in which the in-degree and out-degree of every vertex v is equal to 1: Note that the global constraint circuit is a special case of the global constraint cycle in which the first parameter ncycle is fixed to 1. Thus, the elementary filtering methods for the circuit constraint presented in the last example can be simply adapted to the cycle constraint.
Beldiceanu, within his Global Constraint Catalog [4], proposes the following algorithm: Since all variables in nodes have to take distinct values one can reuse the algorithms associated with the alldifferent constraint.A second necessary condition is to have no more than max(D ncycle ) strongly connected components.Since all the vertices of a circuit belong to the same strongly connected component, an arc going from one strongly connected component to another strongly connected component has to be removed.
This method is redundant.We will prove that an arc going from one strongly connected component to another one will be detected during pruning according to a directed matching.
Theorem 9 Let D = (V, E) be a directed graph associated with the global constraint cycle, a bipartite graph BR(D) be the bipartite representation of D, and let M be a perfect matching in BR(D).Then an edge (v i , v j ) belongs to some perfect matching in BR(D) if and only if vertices v i and v j belong to the same strongly connected component of D.
Proof: Since bipartite representation BR(D) contains a perfect matching if and only if a digraph D has a cycle factor, thus when we take an arc e going from a strongly connected component S i to another strongly connected component S j , then we can never return to S i in order to create a cycle involving the arc e.Hence, all such connecting arcs do not belong to any perfect matching.
Moreover, a lower bound on the number of vertex-disjoint cycles in a digraph D is equal to the number of strongly connected components.Clearly, if the number of strongly connected components equals ncycle, then, for each connected component, we can enforce pruning according to the global constraint circuit, as discussed earlier.
However, the problem of finding an upper bound on the number of vertexdisjoint cycles in a given digraph D is NP-hard to compute.We will see that the maximum number of vertex-disjoint cycles in a digraph D is related to the minimum number of vertices in D needed to eliminate all cycles of D.
An upper bound on the number of the disjoint cycles can be obtained by solving the feedback vertex set problem.We will use some additional notation and terminology.Given a directed graph D = (V, E), a feedback vertex set (abbreviated as FVS) is a set of vertices whose removal leaves an acyclic digraph.The problem is to find such a set with minimum cardinality.Obviously, forests and acyclic digraphs have a value of 0 since they have no cycles.In the literature, the term cycle cutset (or cutset in the short) has appeared as a synonym for feedback vertex set.
For a digraph D we denote by ν(D) the maximum number of vertex-disjoint cycles, and by τ (D) the minimum number of elements in a feedback vertex set of D. Clearly, we have ν(D) ≤ τ (D) and it is easy to construct an infinite family of digraphs such that only inequalities hold.Indeed, let D = (V, E) be a digraph with vertex set V (D) = {x 1 , x 2 , x 3 , x 4 , y 1 , y 2 , y 3 , y 4 } and arc set In summary, we have the following results: Theorem 10 A lower bound on the number of cycles in the digraph D associated with the global constraint cycle equals the number of strongly connected components in D.

Theorem 11
The problem of determining the minimum number of cycles in the digraph D associated with the global constraint cycle is NP-hard.
Proof: The problem is clearly NP-hard as the answer is 1 if the digraph D has a Hamiltonian circuit, which is known to be an NP-complete task.

Theorem 12
The problem of determining the maximum number of cycles in the digraph D associated with the global constraint cycle is NP-hard.
A natural greedy algorithm for finding the maximum number of vertexdisjoint cycles is to, repeatedly, find and remove the vertices belonging to the smallest cycle in the current digraph, until there are no more cycles left.
Karp [36] was the first to prove that the FVS problem is NP-complete (see also [25,Problem GT7]).It is thus not surprising that the above mentioned decision problem for the maximum number of vertex-disjoint cycles is also NPcomplete.
Notice that the computing of the maximal number of vertices such that the corresponding induced subdigraph forms a directed acyclic graph is equivalent to enforcing satisfiability of the global constraint cutset [21], which holds if its corresponding digraph possesses no vertex-disjoint cycles.Because it is an NP-complete problem, recent research in this area has been concentrated on designing algorithms finding a minimum cutset for a restricted class of digraphs and a relatively small cutset for general digraphs.The algorithm described in [21] returns two vertex sets, S 1 and S 2 , such that Theorem 13 Enforcing hyper-arc consistency on the count variable ncycle of the global constraint cycle is NP-hard.
Proof: It is easy to see that the problem is equivalent to the cycle cover problem.This employs a reduction from the PARTITION INTO HAMILTONIAN SUBGRAPHS problem [25, Problem GT13], originally shown NP-complete by Leslie G. Valiant [63].
Moreover, the count variable ncycle does not have the continuity property.As a counterexample, consider a directed cycle C 3 with a loop attached to every node.Then this digraph contains one or three cycles, but a cycle cover consisting of two cycles does not exist in it.

JGAA, 20(2) 363-410 (2016) 385
When we impose the additional condition that each cycle has only two vertices, then the cycle constraint can be expressed by means of the constraint symmetric alldifferent.This constraint can be then interpreted as covering the associated graph with disjoint circuits of length two.Clearly, there exists in this case no solution of the cycle constraint when the number of variables is odd or ncycle = { n 2 }.A complete filtering algorithm achieving hyper-arc consistency for the symmetric alldifferent constraint was proposed by Régin in [50].Its running time is O(n • m).This complexity has been improved to O(p • m) by making use of decomposition theory, where p denotes the number of maximal extreme sets in the underlying graph (for more details, see [17]).
We now give a summary of the algorithm: If ncycle = {mincycle} then for each strong component S i pruning associated with the circuit(S i ) constraint All steps have a polynomial complexity.Finding the strongly connected components of D requires O(m + n) time and space (see Section 3).The existence of a cycle factor in a digraph can be checked and a cycle factor found, if it exists, in time O( √ n • m) [33].The incomplete filtering algorithm for a cutset constraint has O(m+n•log n) time complexity [21].Hyper-arc consistency for a symmetric alldifferent constraint can be achieved in polynomial time [17].

The DERANGEMENT constraint
The derangement constraint is a special case of the cycle constraint.This constraint enforces the covering of an associated digraph by a set of vertexdisjoint proper cycles.In another interpretation it is required to have a permutation with no fixed points.
The pruning for achieving hyper-arc consistency is simple.It is based on the fact that x i can take the value j if and only if the arc (x i , j) belongs to a cycle factor.From a digraph D associated with the global constraint derangement just remove all loops in an iterative way to obtain a reduced digraph D .This step corresponds to the normalization of the domains of the variables.Then construct an auxiliary bipartite graph BR(D ) and compute a perfect matching in it.There is a one-to-one correspondence between the solution of the constraint and the existence of the perfect matching.Checking the feasibility can be realized in O( √ n•m) time, hyper-arc consistency can be established in O(m) time [15].
From an interpretation point of view this constraint is related to alldifferent with unary constraints x i = i for all i, since the number of cycles is free, and the variables and their domains represent the same set of elements.Observe that the bipartite graph associated with the directed perfect matching is equivalent to the value graph associated with the alldifferent constraint.

The SOFT DERANGEMENT VAR constraint
A problem is over-constrained when no assignment of values to variables is possible to satisfy the constraint.In this situation the goal is to find a compromise which allows some constraints to be violated and search for solutions that violate as few constraints as possible.The cost of the violation can be defined as the number of assigned values that should change in order to satisfy the constraint.This measure is represented by the cost variable z which is to be minimized.
In this section we apply our method to the soft version of the derangement constraint by introducing the notion of deficiency to directed graphs.Some preliminary terminology is needed.Recall that in the maximum matching of G the number of exposed vertices is called the deficiency of G and is denoted by δ(G).Let the deficiency of D be the number of exposed vertices on the outward side of its bipartite representation BR(D).Clearly, the inward side has the same number of exposed vertices if a directed perfect matching does not exist in D.
We aim at computing a lower bound of z in order to check the consistency of the global constraint.The following result is a direct consequence of Theorem 16 from [15].
Theorem 14 Assume that a global constraint can be represented by a directed graph D and there exists a one-to-one correspondence between the solution of the constraint and the directed perfect matching in D. Then a lower bound of the cost variable z equals the deficiency of D. Further, if δ(D) < max(D z ) then all the values of domains of variables are consistent with the global constraint.If δ(D) = max(D z ) then values of the domains which are represented by forbidden arcs can be removed.Otherwise, if δ(D) > max(D z ) then the constraint is inconsistent.
Proof: Recall that a directed perfect matching on a digraph D with n nodes and m arcs can be reduced to a perfect matching on a bipartite graph BR(D) with 2n vertices and m edges.The existence of an instantiation of variables such that a global constraint can become satisfied by changing the value of k variables implies the existence of a maximum matching with 2k exposed vertices (k exposed vertices on the outward side and k exposed vertices on the inward side of the bipartite representation).By definition of the deficiency, 2k = δ(BR(D)), thus k = δ(D).
Using the above result, we can formulate the following filtering algorithm that enforces hyper-arc consistency on the soft derangement var constraint (cf.Algorithm 5 in [15]): The proof of Theorem 14 applies to any constraint whose graph representation resembles D and a solution corresponds to a directed perfect matching.For all such constraints that are consistent, hyper-arc consistency can be achieved in linear time, assuming that the maximum matching in BR(D) is known.Note that this is equal to the complexity of achieving hyper-arc consistency on the hard version of these constraints.
(1,1) 4 (1,1) 1 The consistency of the constraint can be verified as follows.We first construct the bipartite graph BR(D) associated with D, shown on the right side of the figure, and compute a maximum matching in BR(D).The matching has deficiency 2, so δ(D) = 1.
The constraint soft derangement var can be made hyper-arc consistent by applying Algorithm 4. To identify the admissible arcs we use Theorem 6. Variable domains can be now filtered as follows.The cost variable z is equal to the number of variables that should change their values in order to make the constraint satisfied.If δ(D) > max(D z ) we know that the constraint is inconsistent.We update the cost variable z to min(D z ) = δ(D) if min(D z ) < δ(D).Since δ(D) = max(D z ) then all forbidden arcs must be removed from the digraph D. The edge (2, 3 ) is forbidden, so the value 3 is deleted from the domain of x 2 .Then our constraint is hyper-arc consistent.
The variables that need to be changed in order to obtain the solution satisfying the constraint are vertices of BR(D).These are variables x 1 and x 3 .Since δ(D) = 1, one variable needs to change its value in order to satisfy the constraint.The variable x 1 or x 3 can take the value 4. In the first case the digraph is covered with a cycle 1 → 4 → 3 → 2 → 1, in the second case the cycle factor of D consists of two 2-cycles 1 → 2 → 1 and 3 → 4 → 3.

The TREE constraint
In this example we provide a quick description of the tree constraint.The tree constraint partitions a given directed graph into a forest of vertex-disjoint directed trees, where only certain vertices can be tree roots.More precisely, the digraph is partitioned into a set of vertex-disjoint anti-arborescences 4 .
More formally, the global constraint tree has the form tree(ntree, nodes), where ntree is a domain variable specifying the number of trees in the tree partition, and nodes is a collection of n variables whose domains consist of elements of {1, . . ., n}.The constraint holds if the associated digraph D is covered by a set of ntree trees in such a way that each vertex of D belongs to one distinct tree.The arcs of the trees are directed from their leaves to their respective roots.
A hyper-arc consistency filtering algorithm for the global constraint tree is described in [6].This algorithm is based on the necessary and sufficient conditions that we now very briefly describe.
Before sketching a filtering algorithm for pruning the tree constraint, we introduce some terminology regarding digraph D = (V, E) and strong component graph SC(D) associated with the tree constraint.These definitions and notations are introduced in the original version of [6]: • A strongly connected component of D that contains at least one potential root is called a rooted component.
• A vertex v is a door of the strongly connected component if there exists an arc (v, w) ∈ E such that v and w do not belong to the same strongly 4 A digraph D is an anti-arborescence with anti-root r if and only if for each vertex v in D there is a path from v to r and the underlying undirected graph of D is a tree.JGAA, 20(2) 363-410 (2016) 389 connected component of D.
• A vertex v is a winner if v is a door or a potential root.
• An arc (v, w) ∈ E such that v and w do not belong to the same strongly connected component is called a connecting arc.
• Similarly, an arc (v, w) ∈ E such that v and w belong to the same strongly connected component is called a non-connecting arc.
• Enforcing an arc (v, w) of D corresponds to removing from D all arcs (v, u) such that u = w.
Let D be a digraph associated with the tree(ntree, nodes) constraint and let SC(D) be a strong component graph of D. Let mintree and maxtree respectively denote a lower and an upper bound on the number of trees for partitioning the digraph D into a set of vertex-disjoint anti-arborescences.mintree is equal to the number of sink components in SC(D) (the number of strongly connected components in D with no outgoing arcs) and maxtree is equal to the number of potential roots in D. These bounds are sharp, this means that, for every mintree ≤ ntree ≤ maxtree, we can construct the partition of edges into ntree vertex-disjoint trees.This also shows that the variable ntree has the continuity property.The constraint tree has at least one solution if and only if all sink components of D contain at least one potential root and D ntree ∩ [mintree, maxtree] = ∅ (see Proposition 3 in [6]).
In the original filtering algorithm proposed in [6] the constraint is propagated according to the strong articulation points of D. Recall that a strong articulation point of a strongly connected component S is such a vertex s that if we remove it then S will be broken into at least two strongly connected components.Equivalently, s is a strong articulation point of D if and only if D − {s} has more strongly connected components than D. The strong articulation points can be found in linear time [34].However, it was shown in [22] that the concept of strong articulation points is not practical and the authors propose a new formulation of pruning rules based on dominators.
Recall that in a flowgraph G a vertex v dominates another vertex w with respect to a designated start vertex s if every directed path in G from s to w contains v. From the above definition, it can be easily seen that every vertex dominates itself.Also, it can be seen that the initial vertex s dominates all the vertices in the digraph.Hence, if both u and v dominates w, one of u and v dominates the other.
Here are some properties of the dominance relation.
• For all x, x dominates itself (reflexivity).
• If x dominates y and y dominates x, then x = y (antisymmetry).
• If x dominates y and y dominates z, then x dominates z (transitivity).
• If x dominates y, then y does not dominate x (asymmetry).
• If x and y both dominate z, then either x dominates y or conversely.
• There may exist vertices x and y such that neither x dominates y nor y dominates x.
Hence, dominance relation is a partial order (for short, a poset).Improving on a previous work by Tarjan [59], who discovered an O(m + n • log n)-time algorithm for finding dominators in an arbitrary digraph, Lengauer and Tarjan [40] proposed an O(m•log n)-time algorithm and a more complicated O(α(m, n)•m)time version, where α(m, n) is an extremely slow-growing functional inverse of the Ackermann function [60].An implementation of this algorithm in linear time is presented in [1].
Theses dealing with dominators are [27] (see also [48]).An excellent general reference to filtering algorithms for tree partitioning constraints using a flowbased modeling is [43].
In terms of the graph partitioning constraints, dual concepts relating to dominators can be defined and utilized.A vertex d is a dominator of v with respect to a winner w if and only if there is no path from v to w in D − {d}.Other variants of the notion are defined analogously.
Clearly, every dominator is a strong articulation point, but not conversely (cf. Figure 6.8 and Figure 8.1 in [48]).Hence, using dominators instead of strong articulation points leads to the better filtering.
In general, if vertex u dominates vertex v then arc (v, u) does not belong to any solution.This follows from the fact that if every path from u to w requires v, then any path from v to u has to be forbidden.
Let us consider S i , 1 ≤ i ≤ p, a strongly connected component of D, and let D i be a set of dominators of S i defined with respect to the winners in S i .The removal of any dominator d ∈ D i creates two kinds of strongly connected components (for more details, see [9]): • ∆ d is the (possibly empty) set of strong components from which no winner of S i can be reached by a path that does not contain the dominator d, • ∆d is the (possibly empty) set of strong components from which at least one winner of S i can be reached by at least one path that does not contain the dominator d.
In addition, among the strongly connected components of ∆ d three types thereof, possibly empty, may be further distinguished: d is the set of the remaining strong components (neither sources nor sinks).
Let us consider some interesting properties of these strongly connected components.
• Let d be a dominator in strongly connected component S i with respect to winners.Then d belongs to all paths from any vertex of ∆ d to any vertex of ∆d .
• If there exists a path factor in D then there exists a Hamiltonian path in ∆ d leading from the source component ∆ + d to the sink component ∆ − d , and finishing on the dominator d (see [9,Proposition 1]).
• Let dom(v) be the set of vertices dominated by a vertex v and let d be a dominator in S i with respect to winners.Then Pruning is then performed according to the following rule, which prevents the creation of (proper) cycles: Theorem 15 An arc (d, i) of a dominator d that reaches a vertex i of ∆ d is forbidden.
Proof: The claim follows from the fact that enforcing such an arc would lead to some strong components with no winners, and hence creating a cycle, which is a contradiction.
We now give a summary of the full algorithm: The presented filtering algorithm has a linear time complexity [22].Computing the strongly connected components of D takes O(m + n) time (see Section 3).Checking that each sink component of D contains at least one potential root takes O(n) time.Testing whether maxtree < min(ntree) or max(ntree) < mintree takes O(1) time.Pruning according to dominators (Theorem 15) can be easily performed in linear time [1].

The BINARY TREE constraint
The binary tree constraint is derived from the tree constraint, which enforces the partitioning of an associated digraph into a set of vertex-disjoint binary trees.
The constraint has the form binary tree(ntree, nodes), where ntree is a domain variable specifying the number of binary trees in the tree partition, and nodes is a collection of n variables whose domains consist of elements of {1, . . ., n}.The constraint holds if the associated digraph D is covered by a set of ntree binary trees in such a way that each vertex of D belongs to one distinct tree.
The filtering algorithm for the binary tree constraint is not known.We show how to handle this constraint by means of the method described in this paper.Although the proposed algorithm does not achieve hyper-arc consistency (the problem to find a spanning tree in which no vertex has degree larger than some given integer is NP-complete [25, Problem ND1]), it is relatively simple to implement.
For any proper forest of binary trees the following holds: (0, 1) for leaves (1, 1) for internal nodes (1, 0) for roots (0, 1) for leaves (2, 1) for internal nodes (2, 0) for roots We model the tree constraint by the associated digraph D in which the vertices represent the variables and the arcs represent the successor relation between them.Let R be the set of potential roots.In order to obtain the digraph D associated with the binary tree constraint we add one dummy vertex v 0 to the input digraph D and declare that each of its predecessors is a potential root in R.
We construct a bipartite graph associated with the global constraint as described in the sequel with the following minor modifications.The vertices on both sides correspond to variables and there is an edge {v i , v j } if and only if j ∈ D xi and i = j.With every vertex we associate two functions g and f such that for each vertex v i on the outward side we set g(v i ) = f (v i ) = 1 (since every vertex must have only one successor) and for the vertex v j on the inward side we set g(v j ) = 1 and f (v j ) = 2 for roots and internal nodes (since every vertex can have at most two predecessors).Additionally, we connect all the vertices representing potential roots to a single vertex labeled ntree and set g(ntree) = min(D ntree ) and f (ntree) = max(D ntree ).Then, we use the filtering algorithm described in [15] to determine the partition of edges and the bounds of the ntree variable.
( On acyclic digraphs, it is easy to see that the feasibility can be checked in polynomial time by computing the perfect (g, f )-matching in the bipartite graph associated with the constraint.Hyper-arc consistency can then be achieved in linear time by determining the partition of edges.Since there are no cycles in the digraph D, the matched edges in the bipartite graph BR(D) will form the partition into the forest of vertex-disjoint binary trees (see Figure 5).
Our algorithm has the following form: Algorithm 6 Partial filtering algorithm for the binary tree constraint Require: Digraph D associated with binary tree(ntree, nodes) Ensure: Incomplete pruning Pruning associated with the tree constraint Pruning according to a directed matching

The PATH constraint
From an interpretation point of view, the path constraint is the unary tree constraint.This constraint requires the partitioning of a directed graph D into a set of vertex-disjoint (directed) paths.
The constraint has the form path(npath, nodes), where npath is a domain variable specifying the number of paths, and nodes is a collection of n variables.The constraint holds if the associated digraph D is covered by a set of npath paths in such a way that each vertex of D belongs to a single path.The arcs of the partition are directed from initial points to potential roots.
For this constraint there already exists a flow-based pruning algorithm to enforce partial filtering [9].However, the bottleneck of the propagation algorithm relies on the detection of the arcs between two strongly connected components that do not belong to any feasible flow.This problem is polynomial, but the existence of an efficient algorithm, which is not based on a repetitive test of each arc, was stated as an open problem.In this example we will demonstrate that such approach is not well suited to practical implementations and propose a new formulation of the pruning conditions based on directed matching.The important point is that our technique does not need the concepts of maximum antichains and inter-scc arcs.
A directed Hamiltonian path problem is NP-complete [25,Problem GT39].The problem can be solved in polynomial time for acyclic digraphs.For any proper path the following holds: Proof: This follows from the fact that there is no path between two vertices that belong to two distinct source components of D. Similarly, there is no path between two vertices that belong to two distinct sink components of D. Thus, the rule requires that the number of source and sink components must be less than or equal to the minimum number of directed paths.
However, the number of sink components in SC(D) is not a sharp lower bound for the number of paths in D. In fact, finding a sharp lower bound makes the problem NP-complete, since we can easily reduce the Hamiltonian path problem to this problem.A sharper lower bound on the number of disjoint paths is introduced by the following result.
Theorem 17 A lower bound on the number of vertex-disjoint paths in the digraph D associated with the path constraint is equal to max{1, δ(D)}.
Proof: According to Theorem 6, we already know that the cycle factor problem in a digraph D is equivalent to the perfect matching problem in a bipartite graph BR(D).We can deduce from this that if the bipartite graph contains a perfect matching then the cycle factor becomes the path factor, since all paths which form a solution are cycles.However, if in the bipartite graph corresponding to the path constraint the maximum matching is not perfect then certain vertices are exposed and the construction will then produce a partition of D in which some of the cycles are "broken" and become paths instead.We show that from any maximum matching M of BR(D) we can build a partition of D consisting of at least δ(D) vertex-disjoint paths.For this purpose consider a digraph D and a maximum matching M in BR(D).Let k = δ(D).The maximum matching M ensures that the partition of D consists of at least k connected components such that each one is a cycle or a path.This follows from the fact that for each arc e ij = (v i , v j ) of D, either e ij ∈ M or e ij / ∈ M and for each vertex v i of D there is at most one arc that belongs to a solution.Thus, the matching M in BR(D) generates a subdigraph of D induced by |M | arcs and composed of at least k vertex-disjoint paths.
Theorem 18 An upper bound on the maximum number of paths for partitioning the digraph D associated with a path constraint is the number of potential roots of D (i.e., maxpath).
Proof: The proof of this theorem follows in the same manner as the proof of Proposition 2 in [6].Since each path has a distinct root, we cannot have more paths than the number of potential roots.
Both the directed perfect matching in D and the smallest possible number minpath of paths can be found in O( √ n • m) time [33].Observe that in the case of non-acyclic digraphs the non-sharp lower bound on the number of vertexdisjoint paths introduced by Theorem 17 can be generalized to the sharp lower bound.This follows from the fact that some matched edges in BR(D) form a cycle in D, which reduces the minimum number of vertex-disjoint paths at the most by 1.
We create a directed graph D associated with the path constraint as follows.The vertices correspond to variables and there is an arc (v i , v j ) if and only if j ∈ D xi and i = j.We add a new dummy vertex v 0 representing count variable npath.There is an arc from v i to v 0 if and only if i ∈ D xi .With every vertex we associate two pairs of functions g = (g − , g + ) and f = (f − , f + ) such that for each vertex v i we set g We construct a bipartite graph associated with the path constraint as follows.The vertices on both sides correspond to variables and there is an edge {v i , v j } if and only if j ∈ D xi and i = j.With every vertex we associate two functions g and f such that for each vertex v i on the outward side we set g(v i ) = f (v i ) = 1 and for the vertex v j on the inward side we set g(v j ) = 0 and f (v j ) = 1.Additionally, we connect all the vertices representing potential roots to a single vertex labeled npath and set g(npath) = min(D npath ) and f (npath) = max(D npath ).Then, we use the filtering algorithm described in [15] to determine the partition of edges and the bounds of the npath variable (see Figure 6).
Since a path factor in an acyclic digraph has no cycles, this implies that the path factor for acyclic digraphs is easy to find.Observe that the path constraint is very similar to the alldifferent constraint, except that the potential roots have to be handled differently.In order to avoid cycles we have the additional restriction that each vertex on the path is not visited more than once, initial endpoints are excluded from the set, every element is distinct and must appear once yet the numbers representing potential roots appear exactly twice.On the bipartite representation BR(D) of D the outgoing non-loop arcs (r, v) are forbidden and will be detected by pruning with respect to a directed matching.
Proof: Observe that if npath is equal to maxpath then all the loops will be enforced and all the outgoing non-loop arcs will be removed during the pruning based on a directed matching.We present a very simple proof of this fact.First of all, if the condition holds then every edge adjacent with the vertex npath in BR(D) is mandatory.Thus, every other edge leading from some neighbor of npath to an inward vertex, distinct from npath, is forbidden.This follows from the fact that g(x) = f (x) = 1 holds for all vertices on the outward side of the bipartite representation of D.
The similar result holds for the binary tree constraint and the count variable ntree.

Theorem 22
The count variable npath has the continuity property.
Proof: Consider a digraph D and a set of potential roots R. Assume that we have found a path factor of size r < |R|.We can build a path factor of size r + 1 by decomposing one of its paths with respect to its potential roots.These steps may be continued until a path factor of size |R| is achieved.

The MAP constraint
In this example we provide a quick description of the map constraint.Next, we show how the propagation rules used for the constraints circuit, cycle and tree can be implemented to generate a partial filtering algorithm.
The map constraint is a useful global constraint that can be used for covering a graph by a set of disjoint cycles and trees, and for modeling various problems such as random mappings [24], or graph related problems for the vertex-disjoint partitioning of graphs.However, before we define it more formally we need the description of the map.For a map, we take the definition from [54, page 459]: Every map decomposes into a set of connected components, also called connected maps.Each component consists of the set of all points that wind up on the same cycle, with each point on the cycle attached to a tree of all points that enter the cycle at that point.
The global constraint map has the form map(nbcycle, nbtree, nodes), where nbcycle and nbtree are domain variables, and nodes is a collection of vertices, which domain designates the successor vertex that will be used in the covering.The variables nbcycle and nbtree are respectively equal to the number of cycles and the number of trees in the partition that can be interpreted as a map.
The map constraint was introduced within the Global Constraint Catalog [4] but no filtering algorithm is known.The purpose of this example is to present an incomplete filtering algorithm for the map constraint.The filter removes inconsistent values by eliminating arcs from the associated digraph, which do not belong to a map.We prove the necessary condition for an arc to be part of the map constraint, which provides the basis for eliminating arcs.
Before we more formally describe a filtering algorithm for the map constraint, we first need to introduce some terminology that will be used throughout this example.We will, as far as possible, use the notation introduced in [6], which we now extend: • A strongly connected component that has a cycle factor is called a cycle component.
• A strongly connected component that has no cycle factor is called a tree component.
Observe that every tree component contains at least one tree.Thus, the number of trees in the map constraint is related to the number of sink components that have no cycle factor.Since a path is a degenerated tree the maximum number of paths in a map constraint is related to the number of trees.
We need to slightly modify the definition of the strong component graph associated with the map constraint.The strong component graph SC(D) is derived from D with the following modification: to each strongly connected component of D that is a cycle component, we associate a vertex with a loop.The vertices without loops represent tree components.
It can be easily shown that if D contains a tree component then it must necessarily contain a tree.Thus, presence of trivial vertices in a digraph associated with the map constraint implies the presence of at least one tree.
We now introduce a theorem that will allow us to reduce the problem of finding the partition of a directed graph to the problem of estimating the bounds on the minimal and the maximal number of cycles and trees.
Theorem 23 Let D = (V, E) be an arbitrary finite (not necessarily connected) digraph such that every vertex has at least one successor.Then there exists a partition of D consisting of cycles, possibly loops, with trees having roots on their vertices.
Proof: One can construct the partition of D from its arcs by first selecting an arbitrary arc among them and then successively adding a new arc in such a way that it has at least one endpoint in common with the arcs already selected.Since the domains are finite, each such sequence must eventually loop back on itself.
Hence, according to this theorem, no pruning is required for the map constraint when there are no given bounds on the number of cycles and the number of trees (e.g.D nbcycle = D nbtree = {0, . . ., n}).Further, every map has at least one cycle (including loops).When the above operation is repeated, starting each time from an element not previously hit, the vertices group themselves into components.This leads to a valuable characterization of such a partition: a map is a set of connected components that are cycles of trees.Thus, every connected component is a collection of rooted trees arranged in a cycle.

Theorem 24
The minimum number of cycles in the digraph D associated with the global constraint map equals the number of sink components in SC(D).
Proof: The claim follows from the fact that every sink component is strongly connected; this means it contains at least one cycle, and there is no path between two vertices that belong to two distinct sink components of D.
Observe that the non-sharp lower bound on the number of cycles in the cycle constraint introduced by Theorem 10 is now generalized to the sharp lower bound on the number of cycles in the map constraint.But the results of Theorem 12 remain still valid.

Theorem 25
The problem of determining the maximum number of cycles in the digraph D associated with the global constraint map is NP-hard.
Proof: The problem of finding the maximum number of vertex-disjoint cycles is related to the problem of determining a feedback vertex set of minimum cardinality.The claim follows now from the fact that the minimum cutset problem is an NP-hard task.
Theorem 26 Given a digraph D associated with the map constraint, an upper bound on the number of cycles partitioning D is given by the minimum feedback vertex set of D.
Proof: The claim follows from the fact that the size of the minimum feedback vertex set in a digraph D is no less than the maximum number of vertex-disjoint cycles in D.
It is easy to see that a map where all the variables have distinct values leads to a set of cycles.Therefore, if digraph D associated with the map constraint has a cycle factor then we can immediately set mintree = 0. On the other hand, if digraph D has only cycles of length 1 (i.e.loops), we have a map that corresponds to a forest of trees and paths, and the algorithm for the tree or path constraint can be used.
Theorem 27 A lower bound on the number of trees in the digraph D associated with the global constraint map is equal to the minimal number of vertex-disjoint proper trees rooted on the sink components of SC(D) and covering all tree components of SC(D).
Proof: According to the definition of the map constraint the number of trees equals the number of arcs that do not belong to any cycle yet their tails are located on a cycle.Therefore, the minimal number of trees is equal to the minimal number of trees in D rooted at the sink components of SC(D).Thus, the claim is trivially derived from the definition of the tree constraint.
Recall that in a topological ordering of a given directed acyclic graph D, each vertex v is associated with a value ord(v), such that for each arc (u, v) we have ord(u) < ord(v) and for each arc (v, w) we have ord(v) < ord(w).The topological ordering can be found in linear time (see Algorithm 1).
In order to compute a lower bound on the number of trees for the map constraint we will impose a constraint increasing nvalue(nval,variables) with the following variables and domains.Let variables be a set of tree components of SC(D).For every tree component s i we put into the domain D si the topological number ord(s j ) of the sink component s j in SC(D) if there is a directed path from s i to the sink component s j .For variable nval we set D nval = {1, . . ., |variables|}.Since enforcing hyper-arc consistency for the increasing nvalue constraint is O(m) [7] the computation of a lower bound on the number of trees is of linear complexity.
According to the property of DAGs we know that from every vertex v there exists a directed path in SC(D) to at least one of its sinks.Thus, we make sure that we will explore a tree and all the trivial vertices of SC(D) will be visited.
We know that for the map constraint the number of trees is the number of vertices directly connected to a cycle.According to this definition a trivial upper bound could be computed as follows: count the number of vertices for which at least one successor (that is not the vertex itself) is a part of a potential cycle.This can be made faster by using the following idea: every vertex that belongs to a strongly connected component containing more than one vertex or having a loop is a vertex that can be on a cycle.Therefore, we should find a vertex that has at least one successor different from those on the cycle.
It turns out that a sharper bound on the maximal number of trees can be obtained by solving the nvalue constraint.More formally, an upper bound on the number of trees in the map(nbcycle, nbtree, nodes) constraint equals n minus the minimum number of distinct values in the nvalue(nval, nodes) constraint, where n is the number of variables and D nval = {0, . . ., n}.Since the computing of the minimum number of distinct values for the nvalue constraint is an NP-hard task [10] then the computing of the maximum number of trees for the map constraint is NP-hard, as well.
Theorem 28 An upper bound on the number of trees for the global constraint map equals n minus the minimum number of distinct values in the nvalue(nval, nodes) constraint, where D nval = {0, . . ., n}.More formally, mintree = n − min(D nval ).
Proof: Let D be a directed graph associated with the map constraint.We will use the induction on the number of trees in D. Suppose that we start from mintree = 0.In this case digraph D has, obviously, a cycle factor.This is the same as the nvalue constraint with D nval = {n}, since each value in nval must appear once, which leads to a set of cycles.Similarly, the case that mintree = 1 is the same as the nvalue constraint with D nval = {n − 1}.This follows from the fact that when n − 1 variables are distinct, two variables must take the same value.Since one value belongs to some cycle the second value is a terminal endpoint of a directed path leading to this cycle.Other cases can be handled similarly.Continuing this process, by the pigeonhole principle 5 , we find that a map having exactly k distinct values has at most n − k trees.A bound is non-sharp since a vertex must not necessarily belong to a cycle.The same argument holds for each of the 1, . . ., n distinct values in the map, so the expected number of trees is obtained by the formula given in the theorem.Thus, we have proven the result.

Theorem 29
The problem of determining the maximum number of trees in the digraph D associated with the global constraint map is NP-hard.
Proof: The claim follows from the fact that computing the lower bound on nval variable of the nvalue constraint is NP-hard.Such a constraint is called atmost nvalue [10].
Since the map constraint is satisfiable when the values nbcycle and nbtree are of allowed range the incomplete pruning algorithm consists of detection forbidden arcs when nbcycle and nbtree are instantiated to one of their extrema.
We demonstrate our algorithm with the following example (the sample digraph is taken from [13, page 23]).The minimum number of cycles is 1 since there exists one sink component S 1 .An upper bound on the number of cycles is 4 since τ (D) = 4.A cutset is, for example, {1, 4, 10, 11}.Note that in our case ν(D) = τ (D).The minimum number of trees is 1 since there exists one path leading to the sink component and covering all tree components of SC(D).An upper bound on the number of trees is 5(= 13 − 8), since min(D nval = 8 for the constraint atmost nvalue.The constraint map holds since the values of count variables nbcycle and nbtree lie within the computed extrema.The reader is invited to check some possible solutions with an arbitrary number of cycles and trees from range 1 . . . 2. We conclude this subsection with a summary of the incomplete filtering algorithm: Evaluating the complexity of the algorithm is done by analyzing the following steps.In order to compute the mincycle value we need to find the strongly connected components of D. This takes O(m + n) time with the algorithm presented in Section 3. In order to estimate the maxcycle value we use the algorithm for the cutset constraint that is of O(m + n • log n) time complexity [21].The existence of a cycle factor can be found in time O( √ n • m) [33].The construction of the strong component graph SC(D) can be easily done in linear time by performing an alternating depth-first search on BR * (D).At the same time, the topological ordering of the vertices of SC(D) may be obtained (see Algorithm 1).The minimum number of trees can be computed in linear time [7].Estimating the maximum number of trees takes O(n 2 ) time when we use one of the approximation algorithms described in [10].Adjusting the variables nbcycle and nbtree can be carried out in constant time.
We analyzed the use of the global constraint map for modeling various problems and for partitioning graphs.We have shown that the constraint can be solved by using the other global constraints such as cutset, nvalue, circuit, cycle, tree or even symmetric alldifferent.

Conclusion
In this paper we have introduced a useful filtering technique based on a directed matching.A general method was described for solving partitioning problems on directed graphs.Such partitioning problems include finding cycles, paths, trees or various maps.In this paper we provided a unified setting for such problems.
Many important graph partitioning constraints are not tractable.For such problems there is in general no algorithm to compute a solutions and no filtering algorithm to remove all redundant values.In this case we must be satisfied with less pruning than the tractable case provides.We have presented efficient methods for incomplete pruning of the variable domains.Our result can be applied to other constraints with a similar graph representation and structure.
We have studied the application of matching theory to the constraints representable by bipartite [15], general [17], weighted [16], and directed graphs (this paper).We have investigated several graph partitioning constraints, some serious and others more entertaining, that can be modeled by directed graphs and filtered by means of structures such as directed matchings, dominators or strongly connected components.
Another natural extension of the matching problem arises when considering weighted directed matchings in digraphs.Our approach can be easily applied to the weighted case.The only difference is that the costs are assigned to the bipartite graph where a directed matching is constructed.However, an open problem would be to describe additional classes of problems that can be modeled by weighted digraphs.
In this paper we have given a partial filtering for the circuit constraint.Another interesting problem is to find a Hamiltonian cycle in a planar graph.In this case we can use for pruning a necessary condition discovered by the Latvian mathematician Emanuel Grinberg [29] in 1968 (see also [56], [65]).The Hamiltonian cycle problem is NP-complete even for planar graphs [26].
In many practical partitioning problems, we have to cover all the vertices of the associated digraph with connected components consisting of at least two vertices.We can extend all the mentioned constraints with the property of a proper partition.
One of the interesting questions for future work would be to apply our approach to balanced constraints such as balance cycle, balance path and balance tree, introduced in [4].These constraints are characterized by the additional parameter measuring the difference between the number of vertices in the smallest pattern and the number of vertices in the largest pattern.
We have proposed an algorithm for the detection of strongly connected components in a directed graph based on a bipartite matching.An open problem is whether a pruning according to dominators and strong bridges can be realized with the help of matching theory.
Finally, note that all algorithms we developed here are practicable and easy to implement.Thus, we expect this work to be relevant for many applications and practical approaches in the field of constraint programming.We consider an empirical evaluation of our algorithms to be an interesting question that deserves further study.

Theorem 2 A
directed graph D = (V, E) has a cycle factor if and only if

Theorem 3
If BR * (D) is the augmented bipartite graph corresponding to the directed graph D, then D is strongly connected if and only if BR * (D) is elementary.

Figure 1 :
Figure 1: Pruning according to a strong connectivity

Theorem 4
For any directed graph D, let G 1 , . . ., G k be the canonical decomposition of BR * (D) into elementary subgraphs.If D i , i = 1, . . ., k, is the subdigraph of D such that BR * (D i ) = G i , then D 1 , . . ., D k are the strongly connected components of D.

Algorithm 1
Computing the strongly connected components Require: Digraph D Ensure: Strongly connected components of D, partition of arcs, and topological ordering of the nodes of SC(D) Construct the augmented bipartite graph BR * (D) associated with the digraph D Start with an initial perfect matching in BR * (D)

Figure 2 :
Figure 2: Pruning according to a directed matching On the left side of the figure a directed graph D in which we wish to find a cycle factor is presented.In the middle of the figure the bipartite representation BR(D) is depicted and a perfect matching M is shown.Observe that the perfect matching in BR(D) corresponds to a cycle factor 1 → 2 → 1 ∪ 3 → 4 → 5 → 6 → 3 in D.In order to obtain the desired partition of edges we need only to apply an alternating depth-first search on BR(D) with respect to M (for more details, see[15, Section 4]).The alternating depth-first forest (computed by the algorithm devised in[15]) is shown on the right side of the figure.Since edge {1 , 3} in BR(D) is forbidden and edge {3, 4 } is mandatory, arc (3, 1) in D is forbidden (drawn as a dashed arrow), and arc(3,4) is mandatory (drawn as a bold arrow).A graph partitioning constraint can be seen as a problem for finding a partial graph of a given digraph associated with the constraint.Graph partitioning constraints are the main subject of the thesis written by Lorca[42].From an interpretation point of view the subdigraphs so obtained are called functional graphs and they have the characteristic property that the out-degree of each vertex is equal to 1 (i.e.every vertex of the partition has exactly one successor).Thus, we will always have g + (v) = f + (v) = 1 for all vertices of D which corresponds to g(v) = f (v) = 1 for all vertices on the outward side of the corresponding bipartite graph BR(D).The graph partitioning constraint can be formally defined as follows.The constraint can be written

Theorem 7
Deciding whether the circuit constraint has a solution is NPcomplete.Proof: We use a transformation from DIRECTED HAMILTONIAN CIR-CUIT [25, Problem GT38] into the circuit constraint.Given a digraph D = (V, E) with n = |V | vertices and m = |E| edges.We construct a circuit constraint, circuit(x 1 , . . ., x n ) in which D xi = {j : (v i , v j ) ∈ E}.The constructed circuit constraint has a solution if and only if the original DIRECTED HAMIL-TONIAN CIRCUIT problem has a solution.

Theorem 8
Suppose S is a vertex separator of a digraph D which separates D into p connected components.Let D S be a digraph induced by S with degree conditions as described in the text.If D has a Hamiltonian circuit then D S has a directed perfect f -matching.Moreover, if an arc e connecting nodes of D S is non-Hamiltonian then this arc is non-Hamiltonian in D. In summary, the following conditions hold: 1.If |S| < p then D is non-Hamiltonian, 2. If |S| = p then every arc connecting nodes of S is forbidden in D, 3. If |S| > p then every arc forbidden in D S is forbidden in D.

Figure 3 :
Figure 3: Pruning of the CIRCUIT constraint

Algorithm 2
Partial filtering algorithm for the circuit constraint Require: Digraph D associated with circuit(nodes) Ensure: Incomplete pruning Remove all loops from the associated digraph D Check the necessary condition whether D is strongly connected If D has more than one strongly connected component, then the constraint is inconsistent If any of the sufficient conditions holds, then the constraint is satisfiable Pruning associated with the alldifferent(nodes) constraint (using perfect matching on BR(D)) If the underlying graph has no perfect 2-matching, then the constraint is unsatisfiable Pruning according to the Gallai-Edmonds Canonical Decomposition Pruning according to a vertex separator All steps have a polynomial complexity.The removal of all loops takes O(n) time.Finding the strongly connected components of D requires O(m + n) time and space (see Section 3).The checking of any the sufficient conditions takes minimal O(1) [41] and maximal O(n 3 ) time [45].A directed perfect matching M can be computed from scratch in time O( √ n • m) [33].A perfect 2-matching of the underlying graph can then be found from M in time O( √ k • m), where k is the number of exposed vertices in G. Pruning according to the Gallai-Edmonds Canonical Decomposition can be performed in O(p • m) time [17],

Algorithm 4
Filtering algorithm for the soft derangement var constraint Require: Digraph D associated with soft derangement var(z, nodes) Ensure: Hyper-arc consistency or constraint not satisfied Remove all loops from the associated digraph D Compute a maximum matching in the bipartite graph BR(D) Compute the Dulmage-Mendelsohn Canonical Decomposition Determine subgraphs G O , G U and G W Determine the partition of edges Let δ denote the deficiency of the subgraph G O If δ > max(D z ) then the constraint is inconsistent If δ = max(D z ) then all forbidden arcs must be removed from the digraph D If δ < max(D z ) then all arcs in D are allowed Update the domain of the cost variable z The algorithm first removes iteratively all the loops from the digraph D associated with the global constraint.Next, it computes a maximum matching in the bipartite graph BR(D).This takes O( √ n • m) time.The next two steps, computing the Dulmage-Mendelsohn decomposition and partition of edges, are of linear complexity.The remaining lines take constant time each.

Algorithm 5
Filtering algorithm for the tree constraint Require: Digraph D associated with tree(ntree, nodes) Ensure: Hyper-arc consistency or constraint not satisfied Compute mintree and maxtree Update variable ntree according to mintree and maxtree values Check the conditions for satisfiability If ntree = {mintree} then any potential root in a non-sink component is forbidden If ntree = {maxtree} then every outgoing non-loop arc of each potential root is forbidden Pruning according to dominators of D (see Theorem 15)

Figure 5 :
Figure 5: Pruning of the BINARY TREE constraint Let minpath and maxpath denote the minimum and the maximum number of paths in a path factor of D. Clearly, maxpath is the number of potential roots for paths (i.e.maxpath = |{i : i ∈ D xi }|).When the number of paths is not fixed (i.e.|D npath | > 1), the key point of any approach solving the path constraint is the evaluation of the lower bound on the number of paths for partitioning the digraph D associated with the global constraint.Theorem 16 Let D be a digraph associated with the path constraint.Denote the number of source components in SC(D) by s and the number of sink components by t.A lower bound on the number of vertex-disjoint paths for partitioning D is estimated by max(s, t).

Figure 6 :
Figure 6: Pruning of the PATH constraint

Figure 8 :Figure 8
Figure 8: Checking feasibility of the MAP constraint

Algorithm 8
Partial filtering algorithm for the map constraint Require: Digraph D associated with map(nbcycle, nbtree, nodes) Ensure: Incomplete pruning If nbcycle = {1} and nbtree = {0} then the constraint specializes into circuit(nodes) If max(nbcycle) > 1 and nbtree = {0} then the constraint specializes into cycle(nbcycle, nodes) Compute mincycle and mintree Estimate maxcycle and maxtree If all sink components of D are loops and their number is equal to nbcycle, and the minimum number of trees is equal to min(nbtree), and the number of vertices in D which have a successor which is located on a sink component of D equals max(nbtree), then the constraint is equivalent to tree(nbcycle, nodes) If nbcycle = {mincycle} then the pruning is equivalent to the pruning for tree(nbtree, tc(d)), where tc(d) denotes a tree component of D, which is created in the following way: every strong component representing sink of SC(D) is contracted to a single vertex with a loop If nbtree = {mintree} then the pruning is equivalent to the pruning for tree(nbtree, tt(d)), where tt(d) denotes a tree component of D, which is created in the following way: the tail of every arc going to a strong component representing sink of SC(D) is replaced by a loop

Table 1 :
Summary of results for graph partitioning constraints (complexities)

Table 2 :
Summary of results for graph partitioning constraints (properties)