

Owing Graph Minimization - rgawdzik
http://anthony-zhang.me/blog/owing-graph/index.html

======
justinnhli
I'm confused. The article seems to require that people pay whoever they owe,
as opposed to whoever is owed money. It seems we can simply sort the people by
the amount owed, then have the person at the top of that list pay the person
at the bottom, and repeat until all debt is resolved. This is an nlog(n)
algorithm (for the sorting), and creates at most n edges (since, for every
transaction, someone either pays back everything they owe, or someone gets
paid everything they are owed).

Is there something I'm missing?

~~~
dragonwriter
> The article seems to require that people pay whoever they owe, as opposed to
> whoever is owed money. It seems we can simply sort the people by the amount
> owed, then have the person at the top of that list pay the person at the
> bottom, and repeat until all debt is resolved.

You could, but that's a solution to a different problem, not a different
solution to the same problem. (Which is the _right_ problem to solve is a
social/customer/domain issue, rather than a technical one.)

~~~
justinnhli
How is it different? By the definition of equivalent in the article:

> when everyone in either graph pays the amounts they owe everyone else, they
> end up with the same amounts in the end.

It seems my algorithm also accomplishes that goal. I'm not sure that my
algorithm is optimal, but I do think it's a good approximation and is somewhat
simpler than the approximation in the article.

~~~
dragonwriter
> How is it different?

On review of the problem statement, it does appear that you are solving the
problem they say they are solving, which appears to lack some of the
constraints that seem to apply to the problem they are _actually_ solving. (I
suspect that the _intent_ here was to show something about graph algorithms
and so the problem statement is just insufficiently constrained, but its
possible that the stated problem really is the interesting problem, and that
the solution is unintentionally overconstrained because someone thought of a
too-clever graph algorithm.)

------
sophacles
The output list makes the tuples different than the input... there is no way
that john suddenly owes beryl 25 for example.

I don't see an explanation for this in the text - but a directed edge seems to
switch from a semantic of "owes" to "is owed".

------
chaoxu
Another way to think of this problem is find a feasible flow in a complete
graph that satisfy all vertex demands and using minimum number of edges.

