Right, there is no algorithmic rule. In the vast majority of cases, it goes to the first reliever who comes in, but there is no rule which says it has to go to him. Even the practice of rewarding the win to a reliever who was in the game when the team took the lead is not a rule. If that reliever is very ineffective, the scorer does not have to give him the win.