Here's a problem that occurs in automatic program analysis. For a set of variables $x_{1}, \ldots, x_{n}$ you are given some equality constraints, of the form " $x_{i}=x_{j} "$ and some disequality constraints, of the form " $x_{i} \neq x_{j} . "$ Is it possible to satisfy all of them? For instance, the constraints
$$x_{1}=x_{2}, x_{2}=x_{3}, x_{3}=x_{4}, x_{1} \neq x_{4}$$
cannot be satisfied. Give an efficient algorithm that takes as input $m$ constraints over $n$ variables and decides whether the constraints can be satisfied.