Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Debt #5

Open
mweinelt opened this issue Oct 21, 2017 · 1 comment
Open

Simplify Debt #5

mweinelt opened this issue Oct 21, 2017 · 1 comment

Comments

@mweinelt
Copy link

If A owes B and B owes C and C owes A we have a loop, which can be simplified to reduce the amount of physical transactions and total money exchanged between users.

The general idea of an algorithm is:

  • Use a weighted, directed graph
  • The weight is the sum of debt between the two vertices, which are users
  • Find a cycle in the graph
  • Find the smallest weight on the cycle
  • Subtract the smallest weight from all weights in the cycle

Simplified!

More References:

@luelista
Copy link
Owner

I'd love to have this and would definitely integrate it if someone would implement the algorithm in PHP or Javascript.
Not sure how quick I'll understand it enough to do it myself... ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants