There is another theory, which is that the person who chooses to have an affair has an emotional brokenness that allows them to choose to have an affair,rather than work on their marriage or divorce.
The way to become a safe partner, whether for your wife, your AP or someone else in the future, is to go to a counsellor by yourself, for months, to work out what it was inside of you that gave you permission to choose an affair. Initially, you''ll probably blame your wife, or some other external reason. But the truth is that many people are in horrible marriages and yet they do not cheat...so it must be something deeper inside you.
And,gently, until you dig deep, work out what it is and work to change it, you will not be a safe partner and,yes, will probably yearn for your AP, or someone else, to fill the hole inside of you.