<p>A new algorithm is proposed for solving the problems associated with discontinuity sources in phase maps. It is based on the stable-marriages algorithm and is implemented as a recursive procedure.</p><p>With this technique, discontinuity sources of opposite sign are connected by a set of cut lines that fulfills a stability criterion and possesses the minimum cut length of the stable sets. The algorithm is fast and easy to implement and has proved efficient, as experimental results show.</p>