recently I have been reading about the Splitwise problem where one has a group of people with debts between each other, and the goal is to settle these debts with the minimal number of transactions. It can also be modeled as a directed weighted graph which edges are to be reduced.
The solution I encountered most often was a greedy iterative algorithm that, firstly, calculates the net outcome of every person (money he is owed - money he owes), and then repeats the following:
1. take max. debtor X and max. creditor Y
2. if X owes more than Y is owed
then X pays Y Y's value
reduce X's debt by Y's value
set Y's value to 0
else X pays Y X's value
reduce Y's value by X's debt
set X's debt to 0
...until everyone's value is 0.
My question(s):
- Is that algorithm really optimal in the transaction amount it produces? If yes, how can this be proved?
- If not, what is a counterexample to this algorithm's optimality, i.e., a situation where the debts can be minimised with less transactions than the ones it outputs?