The Symmetric Alldiff Constraint

The Symmetric Alldiff Constraint
Jean-Charles R E G I N
ILOG
Les Taissounieres HB2
06560 Valbonne, F R A N C E
e-mail : [email protected]
Abstract
The symmetric alldiff constraint is a particular
case of the alldiff constraint, a case in which
variables and values are defined from the same
set 5. T h a t is, every variable represents an
element c of S and its values represent the elements of S that are compatible w i t h c. This
constraint requires that all the values taken
by the variables are different (similar to the
classical alldiff constraint) and that if the variable representing the element / is assigned to
the value representing the element j, then the
variable representing the element j is assigned
to the value representing the element ?'. This
constraint is present in many real-world problems, such sports scheduling where it expresses
matches between teams. In this paper, we show
how to compute the arc consistency of this constraint in
, where n is
the number of involved variables and
the
domain of the variable i. We also propose a
filtering algorithm of less complexity (O(rn)).
1
Introduction
Constraint Satisfaction Problems (CSPs) involve finding
values for problem variables subject to constraints on
which combinations are acceptable. They are more and
more used in real-life applications, such as frequency allocation, crew scheduling, time tabling, car sequencing,
etc. [Simonis, 1996].
The general task of finding a solution in a constraint
network being N P - h a r d , many researchers have concentrated on improving the efficiency of solving a CSP.
Currently, it seems that a look-ahead approach is the
most promising way. The purpose of this technique is
to look at the values of the variables that are not yet
instantiated and to remove values that cannot lead to a
solution w.r.t. the current partial instantiation. Thus,
it anticipates the detection of some failures by using a
particular treatment after each modification of domain
variables. A filtering a l g o r i t h m is one such particular
treatment. W i t h respect to a partial instantiation, it re-
420
CONSTRAINT SATISFACTION
moves once and for all certain inconsistencies that would
have been discovered several times otherwise.
Techniques ba,sed on filtering algorithms are thus quite
i m p o r t a n t . Particularly, arc consistency caught the attention of many researchers, who then discovered a large
number of algorithms.
Furthermore, it is necessary to deal directly w i t h the
arity of the constraints because nonbiliary constraints
lose much of their semantics when encoded into a set of
binary constraints. (See [Regin, 1994].) T h i s encoding
leads, for example, to behavior that prunes much less for
filtering algorithms handling i t .
When the semantics of a nonbiliary constraint is not
known a priori, GAC-Sehema [Bessiere and Regin, 1997]
can be used to achieve arc consistency of the constraint.
However, this algorithm does not perform as well w i t h
known semantics. In such a situation, it is particularly
interesting to develop a specific filtering a l g o r i t h m , as
it was done for the well known alldiff constraint [Regin,
1994]. This approach leads to an important gain in time
and in space for solving a CSP, even if the filtering algor i t h m does not, achieve arc consistency. For instance, the
diff-n or cumulative constraints are really useful in practice to solve real-world problems, as if has been shown
by Simonis, although arc consistency is not achieved for
t h ese constrants.
In this paper, we study a new constraint and propose
some filtering algorithms for it. Some of those algorithms
ensure arc consistency; others are weaker.
The symmetric alldiff constraint
Consider a set of people to be grouped by pairs according to predefined compatibilities such that each person is paired exactly once. T h i s problem can be m o d eled as a constraint satisfaction problem in which each
person is associated w i t h one variable and one value.
The domain of a variable associated w i t h a person p is
defined by the values which are associated w i t h a person compatible w i t h p. For instance, consider the simple problem defined on a set of three people
that are all compatible. The CSP w i l l then involve
three variables
where
is associated w i t h
and three values
where
is associated w i t h
Since we want to p a i r all the variables w i t h different
values, we add an a l l d i f f c o n s t r a i n t i n v o l v i n g all the variables. C o n s t r a i n t s s t a t i n g t h a t " i f any variable x is associated w i t h a variable y, t h e n y m u s t be associated w i t h
x n can be defined by means of the
f u n c t i o n . T h i s funct i o n is defined as follows:
'
is the value v that is associated w i t h the same person as the variable x, and
is the variable x t h a t is associated w i t h the same person
as the value v. Of course, we have
T h e n , for each variable x and for each value ?;, we define
the c o n s t r a i n t :
T h e C S P we have j u s t defined can be viewed as only
one c o n s t r a i n t t h a t we w i l l call symmetric alldiff c o n straint.
T h i s c o n s t r a i n t requires t h a t all the values
taken by the variables are different ( s i m i l a r to the classical a l l d i f f c o n s t r a i n t ) and t h a t if the variable representing
the element i is assigned to the value representing the element j , then the variable representing the element j i s
assigned to the value representing the element i.
T h e e x a m p l e p r o b l e m we consider has no s o l u t i o n .
However, the C S P that has j u s t been built is arc
consistent 1 . T h u s it is i m p o r t a n t to be able to efficiently
handle s y m m e t r i c a l l d i f f constraints.
These constraints arise in some problems such crew
scheduling ( t w o p i l o t s must, be in a cockpit at the same
t i m e ) , nurse rostering ( t w o nurses are required for certain
operations) or sports scheduling. In the latter problems,
one of the m a i n tasks is to c o m p u t e a set of matches
between teams such t h a t each t e a m plays against another t e a m , and each t e a m plavs exa.ct.lv once for each
period of t i m e under consideration. There exist compati b i l i t y constraints between teams. For instance, d u r i n g
the w i n t e r p e r i o d , travel has to be l i m i t e d . Therefore,
for a given p e r i o d , the p r o b l e m we have to solve for each
period is exactly a s y m m e t r i c a l l d i f f constraint.
A s y m m e t r i c a l l d i f f c o n s t r a i n t can be expressed by a
g r a p h , in which nodes represent variables and there is an
edge between t w o nodes x\ and x 2 if and only
and
I n i t i a l l y this g r a p h corresponds to the c o m p a t i b i l i t y
g r a p h . D u r i n g the search for a s o l u t i o n , it is built from
the current d o m a i n of the variables.
Since this new c o n s t r a i n t corresponds to the definition
of a p a r t i c u l a r C S P i n v o l v i n g several constraints, then* is
an equivalence between the consistency of this new cons t r a i n t and the existence of a s o l u t i o n for the CSP. T h i s
equivalence means t h a t an a l g o r i t h m checking the consistency of a s y m m e t r i c a l l d i f f c o n s t r a i n t is more efficient
for the resolution of the p r o b l e m t h a n is the c o n j u n c t i o n
of all the a l g o r i t h m s checking the consistency (or achievi n g arc consistency) of the other constraints involved in
the first m o d e l .
It is q u i t e i m p o r t a n t , to emphasize this point, in order to u n d e r s t a n d t h a t there is great interest in definl
F o r instance,
diff constraint.
satisfies the all-
Figure 1: An example of a symmetric alldiff constraint.
Nodes represent teams, and edges compatibilities between
teams. The left graph is the initial graph, the right graph is
the graph obtained after achieving arc consistency.
ing specific global constraints for w h i c h efficient algor i t h m s c o m p u t i n g the consistency of these constraints
are k n o w n . For instance, consider the p r o b l e m given by
the left graph in Figure 1 and t w o models of this problem. F i r s t , this problem is represented by a classical
alldiff constraint and constraints ensuring the s y m m e tries. Second, the p r o b l e m is represented by o n l y one
s y m m e t r i c alldiff constraint,. T h e subproblems p a r t 1 and
part, II of this graph are o d d size cliques. T h u s , clearly,
if e is not instantiated to neither a nor 6 then there is no
s o l u t i o n " . U n f o r t u n a t e l y , the CSP defined by the first
model is arc consistent, and so no value is removed. T h e
right graph of the figure shows the achievement of arc
consistency for the s y m m e t r i c a l l d i f f c o n s t r a i n t .
T h e consistency of an a l l d i f f c o n s t r a i n t can be c o m puted by searching for a m a x i m u m m a t c h i n g in a b i p a r t i t e g r a p h . We w i l l show that, the consistency of
a s y m m e t r i c alldiff constraint can also be achieved by
searching for a m a x i m u m m a t c h i n g in a graph which is
not necessarily b i p a r t i t e . T h i s p r o b l e m can be easily
solved by using, for instance, Edmonds's a l g o r i t h m [ E d monds, 1965]. We w i l l also present, an o r i g i n a l a l g o r i t h m
for achieving arc consistency for a s y m m e t r i c a l l d i f f cons t r a i n t . I j n f o r t u n a t l y , this a l g o r i t h m is not i n c r e m e n t a l .
Hence, we w i l l propose a f i l t e r i n g a l g o r i t h m , which does
not necessarily achieve arc consistency, b u t which has a
remarkable c o m p l e x i t y .
T h e paper is organized as follows. First, we give some
preliminaries about constraint, network and m a t c h i n g
theory. T h e n , we f o r m a l l y present the s y m m e t r i c a l l d iff constraint, and we explain how to c o m p u t e the consistency of this constraint. In the next section, an alg o r i t h m achieving arc consistency for this c o n s t r a i n t is
f u l l y detailed. A f t e r i t , we propose a f i l t e r i n g a l g o r i t h m
which has lower c o m p l e x i t y . T h e n we conclude.
2
When there is no ambiguity we will say that node x is
instantiated to y instead of saying node x is instantiated to
and node y is instantiated to
BEGIN
421
2
Preliminaries
2.1
A
Constraint network
finite
length of an alternating path or cycle is the number of
edges it contains.
constraint network Af is defined as a set of
finite set of possible values for variable
, and a set C of
constraints between variables. We introduce the particular notation
to represent
the set of i n i t i a l domains of
fies the allowed combinations of values for the variables
. An element
is called a tuple on X(C) \
ind(C, x) is the position of variable x in X(C); #(i>, r)
is the number of occurences of the value v in the tuple
r; and D(X) denotes the union of the domain of the
variables of A'.
A tuple r on X(C) is valid if
A value
I i s consistent with C
i f f i ,
or
, such that a = r[ind(C,x)] and r is valid.
C is arc consistent iff
D(x), a is consistent w i t h C. We achieve arc consistency
of C by removing all values not consistent w i t h C.
The value graph of a constraint C is the bipartite
graph GV(C) = ( X ' ( C ) , D(X(C)), E) where
iff
2.2
Matching theory
Most of these definitions are due to [Tarjan,
If { u , v } is an edge of a graph, then we say that u
and v are the ends or the extremities of the edge, n
are the number of nodes and m the number of edges of
a graph. G — { u , v } denotes the graph G in which the
nodes u and v have been removed. G — {{u, v}} denotes
the graph G in which the edge {u,v} has been removed.
A matching M on a graph is a set of edges no two of
which have a common vertex. The size \M\ of M is the
number of edges it contains. The maximum matching
problem is that of finding a matching of m a x i m u m size.
M covers X when every vertex of X is an endpoint of
some edge in A/.
Let M be a matching. An edge in M is a matching
edge; every edge not in M is free. A vertex is matched
if it is incident to a matching edge and free otherwise.
For any matched vertex v y mate(v) denotes the vertex
w such that {v,w} is a matching edge.
An alternating path or cycle is a simple path or cycle whose edges are alternately matching and free. The
3
Indeed, we consider that any constraint network Af can
be associated with an initial domain D0 (containing V), on
which constraint definitions were stated.
422
C O N S T R A I N T SATISFACTION
The consistency of the classical alldiff constraint is
computed by searching for the existence of a matching
in the value graph that covers all the variables, and arc
consistency is achieved by identifying all the edges that
can never belong to a matching that covers all the variables. Our problem is really close to that one w i t h one
major difference: the graph under consideration can be
non bipartite.
The problem we have to solve is called symmetric
matching. Symmetric matching in a 2n-node bipartite
graph is, indeed, really no different from matching in
an n-node nonbipartite graph. Consider the value graph
GV(C) of a symmetric alldiff constraint. This graph is
bipartite. Now, we can modify this graph by contracting
any variable x w i t h value
into a single vertex.
The edge between x and a is deleted, and the other edges
that have x or a as an endpoint are replaced by edges
having the contracting vertex as endpoint and their other
extremity unchanged. The graph we get in that way, denoted by CGV(C), is no longer bipartite and is called
the contracted value graph of a symmetric alldiff conwhere
IThere is a correspondance between a matching which
covers X(C) in CGV(C) and a tuple of T(C).
P r o p o s i t i o n 1 Given
, every tuple
ofT(C) corresponds to a set A of edges in CGV(C) such
that for each vertex x
X(C), x is an end of exactly
one edge. And a matching M in CGV(C) ivhich covers
X(C) corresponds to an element ofT(C)
proof: An element of T(C) corresponds to a matching that
covers X(C) in CGV(C), by construction of CGV(C). And
from a matching in CGV(C) covering X(C), we can build a
tuple that satisfies the constraint, by definition of the symmetric alldiff constraint.
Therefore, we have:
Corollary 1 A
constraint
is consistent iff there exists a matching that covers X(C) in
CGV(G).
Since GGV(C) can be nonbipartite, an algorithm
searching for m a x i m u m matching in a nonbipartite graph
has to be used, like the blossom-shrinking algorithm
o f E d m o n d s . A n i m p l e m e n t a t i o n o f this a l g o r i t h m i n
0(mn) is f u l l y d e t a i l e d in [ T a r j a n , 1983]. T h e advantage
of this a l g o r i t h m is its i n c r e m e n t a l i t y . Suppose t h a t we
s t a r t w i t h a m a t c h i n g of size k, and there exists a m a t c h ing of size n / 2 ; then t h i s m a t c h i n g can be c o m p u t e d in
0((n/2 - k)7n). T h i s p o i n t is i m p o r t a n t if we systematically check the consistency of the constraint d u r i n g the
search for s o l u t i o n .
On the other h a n d , [ M i c a l i and V a z i r a n i , 1980] proposed a c o m p l e x a l g o r i t h m in
For c o m p u t i n g the consistency of a s y m m e t r i c alldiff
c o n s t r a i n t , it is also necessary to u p d a t e the contracted
value g r a p h . Precisely, when a value is removed f r o m
the d o m a i n of a v a r i a b l e , the corresponding edge must
be deleted. A l l these m o d i f i c a t i o n s need at most O(ni)
operations. T h e r e f o r e , we can consider t h a t the consistency of a s y m m e t r i c a l l d i f f c o n s t r a i n t can be computed
in
3.1
A r c consistency
For the sake of c l a r i t y , we w i l l consider t h a t C =
svmalldiff
is a s y m m e t r i c a l l d i f f constraint. We
w i l l also consider t h a t the consistency of C lifts been
checked; thus M a m a t c h i n g which covers X(C) in
CGV(C) is k n o w n .
F i r s t , for every variables x and y of X(G), we have
to ensure t h a t if
is removed f r o m D(x) then
is also removed f r o m D(y). T h i s can be easily done in
O (1) for each d e l e t i o n .
F r o m p r o p o s i t i o n 1 and by d e f i n i t i o n of arc consistency, we have:
C o r o l l a r y 2 A value a of a variable x is consistent, with
C if and only if the edge
belongs to a matching
that covers X(C)
in CGV(C).
T h u s , the arc consistency of ( ' is achieved by removing all the values (x,a) such t h a t the edge
does not belong to any m a t c h i n g that covers A" ((".')
We can i m p r o v e this c o m p l e x i t y by using the following p r o p o s i t i o n w h i c h has been used for efficiently comp u t i n g arc consistency in the classical alldiff constraint.
T h i s p r o p o s i t i o n , indeed, does not depend on whether
the g r a p h is b i p a r t i t e or n o t .
P r o p o s i t i o n 2 ( [ B e r g e , 1 9 7 0 ] ) An edge belongs to
some but not all maximum
matchings,
iff, for an arbitrary maximum matching, it belongs to either an even
alternating path which begins at a free vertex, or an even
alternating
cycle.
A l g o r i t h m 1: An arc consistency algorithm for a symmetric alldiff constraint.
M is a m a t c h i n g which covers X(C)\ thus no vertex
of A r (C f ) is free. Therefore, a value a of a variable x is
consistent w i t h C iff the edge
belongs to an
even a l t e r n a t i n g cycle. If the edge
belongs to
A / , then the value a of x is consistent w i t h C. T h u s , the
value a of x is not consistent w i t h C if and o n l y if the
e
dge
is free and if it does not belong to an altern a t i n g cycle. Such an a l t e r n a t i n g cycle is formed by an
a l t e r n a t i n g path
and the m a t c h e d
edge {mate(x),x}. Therefore the problem of the search
for an a l t e r n a t i n g cycle is equivalent to the p r o b l e m of
the search for an a l t e r n a t i n g p a t h f r o m x to rnatr(x) in
CVGWe can give the a l g o r i t h m achieving arc consistency.
For each m a t c h i n g edge {u, v} in CGV(C), we search for
an a l t e r n a t i n g path f r o m v. to v in GGV(G) - {{v;, u } } ,
but we do not stop if we reach an edge w i t h v as its
extremity. If such an edge is reached, it is m a r k e d as
" v a l i d " and the a l g o r i t h m continues as if the edge does
not exist. W h e n there are no more edges to study, the a l g o r i t h m stops. A l l edges { v , y } different, f r o m [v,u] t h a t
are not marked valid cannot belong to an even alternating cycle. Afterwards, we apply the same reasoning by
s t a r t i n g f r o m v in order to identify the v a l i d edges {x, u}.
(See A l g o r i t h m 1.)
The problem which remains is the c o m p u t a t i o n of alt e r n a t i n g paths.
An a l t e r n a t i n g path from x to rnatc(x) in CGV(C) —
{{mate(x), x}} can be found by a p p l y i n g the f o l l o w i n g
procedure due to Edmonds, x is marked even; then we
m a r k even a vertex reached f r o m a m a t c h i n g edge, and
odd a vertex reached from a free edge. T h u s , f r o m any
even vertex u., we traverse the free edge having an ext r e m i t y in u. A n d f r o m any odd vertex v, we traverse
the m a t c h i n g edge linked to v. Note t h a t a vertex is even
if it is an even distance f r o m the s t a r t i n g vertex and odd
otherwise. T h i s m e t h o d works fine for a b i p a r t i t e graph
because there is no o d d - l e n g t h cycle, so a vertex m a r k e d
even can never be reached f r o m a vertex also marked
even.
On n o n b i p a r t i t e graphs, there is a subtle d i f f i c u l t y :
a vertex can appear on an a l t e r n a t i n g p a t l i in either
parity. (See Figure 2.) Such an anomaly can occur only
if G contains an a l t e r n a t i n g p a t h p f r o m a vertex s to an
even vertex u and an edge f r o m u to another even vertex
w on p. T h e odd-length cycle f o r m e d by { u , w] and the
part of p f r o m w to u is called a blossom. In Figure 2,
{c, d, e, f, g} f o r m a blossom.
REGIN
423
F i g u r e 2: The problem with nonbipartite graphs. Suppose
that we search whether {a, 6} belongs to an alternating cycle.
[a, 6, c, c/, e] marks e even, whereas [a, 6, e, g, /, e] marks e odd
and h cannot be reached.
E d m o n d s proposed an a l g o r i t h m t h a t is able to deal
w i t h this d i f f i c u l t y . Since any vertex in a blossom can
be reached f r o m an a l t e r n a t i n g p a t h f r o m the base in
either p a r i t y , it s h o u l d be possible to traverse any free
edge t h a t has a vertex in the blossom if we do n o t want
to miss an a l t e r n a t i n g p a t h . As rioted by E d m o n d s , this
can be easily o b t a i n e d by m a r k i n g all the vertices of a
blossom as even.
A l g o r i t h m 2 proposes an a d a p t a t i o n to o u r purpose of
E d m o n d s ' s a l g o r i t h m . Since E d m o n d s ' s a l g o r i t h m cannot miss any a l t e r n a t i n g p a t h s the arc consistency algor i t h m t h a t we have proposed is exact.
A l g o r i t h m 2 traverses each edge at most twice,
because the arc ( u , w ) is i n t r o d u c e d in the list of
arcs to s t u d y when u is m a r k e d even and a node
is m a r k e d even o n l y once.
Moreover, when an
arc is traversed it is removed f r o m ArcsToStudy.
Thus,
the c o m p l e x i t y o f this a l g o r i t h m depends
on the f u n c t i o n s belongToI.)ifferent.Blossom(w, v) and
c o m p u t e N e w B l o s s o m ( ? / , v).
T h e f u n c t i o n b e l o n g T o D i f f e r e n t B l o s s o m ( u , v) determ i n e whether u and v belongs to different blossoms. If
this f u n c t i o n is t r u e , then a new blossom is detected.
T h e f u n c t i o n c o m p u t e N e w B l o s s o m ( u , v) determines the
nodes i n v o l v e d in the new blossom and updates internal d a t a structures needed by the first f u n c t i o n . T a r j a n
has proposed an efficient and b e a u t i f u l i m p l e m e n t a t i o n
of t h e m based on a u n i o n - f i n d s t r u c t u r e . We w i l l not
present it here because it is f u l l y d e t a i l e d in [ T a r j a n ,
1983] p 121 122. T h i s p a r t i c u l a r i m p l e m e n t a t i o n leads
to an a l g o r i t h m in 0[m). T h u s , we w i l l consider t h a t
the c o m p l e x i t y of A l g o r i t h m 2 is O(rn).
T h e r e f o r e , the c o m p l e x i t y of the arc consistency a l g o r i t h m is 0{nm) because there are 2n calls to A l g o r i t h m 2. However, this a l g o r i t h m is not i n c r e m e n t a l . In
f a c t , each t i m e arc consistency is achieved, it w i l l be
necessary to call a procedure 2n t i m e s in O(rn).
For
c e r t a i n p r o b l e m s , t h i s c o m p l e x i t y can prevent t h i s algor i t h m f r o m being s y s t e m a t i c a l l y used d u r i n g the search
for s o l u t i o n s . T h u s , in the n e x t section, we propose a
filtering a l g o r i t h m t h a t does not necessarily ensure arc
consistency, b u t it has a c o m p l e x i t y t h a t allows its syst e m a t i c use d u r i n g the search for s o l u t i o n s .
424
C O N S T R A I N T SATISFACTION
3.2
Another filtering algorithm
P r o p e r t y 1 Le.t {?/, rnate(u)} be a matching edge.
If
{a,mate(u)} is traversed by Algorithm 2, then all edges
that belong to
an
even
alternating cycle containing
{ii,mate(u)}
are also traversed by the algorithm.
T h i s p r o p e r t y holds because E d m o n d s ' s
c a n n o t miss any a l t e r n a t i n g p a t h s .
P r o p o s i t i o n 3 Let M
CGV(C).
Then any free
one of its ends is reached
traversed by Algorithm 2
matching.
algorithm
be matching that covers X(C) in
edge {u, v} such that at least
by Algorithm 2 and {u, v) is not
cannot belong to a maximum
p r o o f : The ends of {u, v} cannot be even; otherwise, this
edge would have been traversed by Algorithm 2. Consider
that v has been reached, then v is marked odd. The matching covers all the vertices and v is odd, thus the matching
edge {mate(v), v} has been traversed. v; belongs to only one
matching edge, so every alternating cycle containing { u , v}
contains also {mate(v), v}. Furthermore, by Property 1, all
the edges that belong to an even alternating cycle containing
{v,matc(v)} are traversed by the algorithm. Hence, if { u , v]
is not traversed by the algorithm then { u , t ; } does not belong
to any maximum matching.
F r o m t h i s p r o p o s i t i o n , we propose a filtering algor i t h m . We choose any vertex x\ then we a p p l y A l g o r i t h m 2 to i t . Each free edge {x, u) w h i c h is n o t m a r k e d
v a l i d is r e m o v e d . T h e n , each edge w h i c h satisfies P r o p o s i t i o n 3 is also r e m o v e d . If at least one edge is removed
Figure 3: An example of the filtering algorithm for a symmetric alldiff constraint. The bold edges represent the matching edges. The edge { / , / * } is not traversed, so
i.s removed from D(h), and
) is removed from D(f).
by the previous procedures, then we choose any other
vertex t h a t has n o t already been chosen, and we repeat
the previous o p e r a t i o n . If no edge is removed, we stop
the a l g o r i t h m . (See F i g u r e 3.) If no deletion occurs, the
c o m p l e x i t y of the a l g o r i t h m is O ( m ) , and for each delet i o n , the c o m p l e x i t y of this a l g o r i t h m is also O(rn). T h e
advantage of this approach is t h a t (he c o m p l e x i t y can be
a m o r t i z e d for each d e l e t i o n .
some edges are removed. T h e previous a l g o r i t h m can be
independently applied to each connected c o m p o n e n t of
the graph. On other h a n d , note t h a t if CGV(C) contains
a connected c o m p o n e n t w i t h an o d d n u m b e r of nodes,
then there is no s o l u t i o n . T h i s observation means t h a t
if there is a 2-connected c o m p o n e n t w i t h an o d d n u m ber of nodes and c o n t a i n i n g exactly one c u t p o i n t of the
g r a p h 4 , then this c u t p o i n t cannot be matched w i t h another node of the c o m p o n e n t . S i m i l a r l y , if there is a
2-connected component w i t h an even n u m b e r of nodes
and containing exactly one c u t p o i n t of the g r a p h , then
this c u t p o i n t cannot be matched w i t h a node t h a t does
not belong to the 2-connected component. Such c o m ponents can be identified easily in O(rn). Moreover, if a
node in C(JV(C) has only t w o neighbors, then these t w o
neighbors cannot be matched together. F u r t h e r m o r e , it
is also interesting to use the classical alldiff constraint
and arc consistency for this constraint.
4
Conclusion
In this paper we have presented the s y m m e t r i c a l l d i f f
constraint. T h i s constraint is present in m a n y real-life
applications. We have shown how arc consistency for
this constraint can be achieved in O(nm). We have also
proposed a filtering a l g o r i t h m t h a t does not ensure arc
cousistencv but has a c o m p l e x i t y t h a t can be used in
practice because it can be amortized for each deletion
{()(rn) per deletion).
References
[Beige, 1970] C Berge.
Paris. 1970.
Graphe
et Hypergraphes.
Dunod,
[Bessiere and Begin, 1997] C. Bcssiere and .J-C Begin. Arc
consistency for general constraint networks: preliminary
Jesuits.
In Proceedings of IJCAI'97, pages 398-404,
Nagoya, 1997.
[Edmonds, 1965)] J. Edmonds. Path, trees, and flowers. Can.
./. Math., 17:449-407, I965.
[Micali and Vazirani, 1980] S. Micali and V.V. Vazirani. An
algorithm for finding maximum matching in
general graphs. In Proceedings 21st FOGS, pages 17-27,
1980.
[Begin, 1994] J-C. Begin.
A filtering algorithm for constraints of difference in CSPs. In Proceedings AAA1-94,
pages 362 -367, Seattle, Washington, 1994.
However, we can o b t a i n a better a m o r t i z a t i o n . Suppose t h a t d u r i n g one pass of the previous a l g o r i t h m 10
edges are removed. T h e n , if the next 10 passes delete no
edges, the a m o r t i z e d c o m p l e x i t y w i l l r e m a i n O(rn) per
deletion. A l g o r i t h m 3 is a possible i m p l e m e n t a t i o n of
this idea.
T h i s a l g o r i t h m does n o t ensure arc consistency because A l g o r i t h m 2 traverses some edges t h a t do not belong to an even a l t e r n a t i n g p a t h .
In practice, t h i s a l g o r i t h m can also be improved by
using some heuristics. It is i m p o r t a n t to take care about
the possible creation of new connected components when
[Sinionis, 1996] I I . Simonis. Problem classification scheme
for finite domain constraint solving. In CP96, Workshop
on Constraint Programming Applications:
An Inventory
and Taxonomy, pages 1-26, Cambridge, M A , USA, 1996.
[Tarjan, 1983] B.E. Tarjan. Data Structures and Network Algorithms. CBMS-NSF Regional Conference Series in Applied Mathematics, 1983.
4
A cutpoint is a node whose deletion increases the number
of connected components of the graph.
REGIN
425