  We introduce the problem of adapting a stable matching to forced and
forbidden pairs. Specifically, given a stable matching $M_1$, a set $Q$ of
forced pairs, and a set $P$ of forbidden pairs, we want to find a stable
matching that includes all pairs from $Q$, no pair from $P$, and that is as
close as possible to $M_1$. We study this problem in four classical stable
matching settings: Stable Roommates (with Ties) and Stable Marriage (with
Ties). As our main contribution, we employ the theory of rotations for Stable
Roommates to develop a polynomial-time algorithm for adapting Stable Roommates
matchings to forced pairs. In contrast to this, we show that the same problem
for forbidden pairs is NP-hard. However, our polynomial-time algorithm for the
case of only forced pairs can be extended to a fixed-parameter tractable
algorithm with respect to the number of forbidden pairs when both forced and
forbidden pairs are present. Moreover, we also study the setting where
preferences contain ties. Here, depending on the chosen stability criterion, we
show either that our algorithmic results can be extended or that formerly
tractable problems become intractable.
