You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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... ;-)
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:
Simplified!
More References:
The text was updated successfully, but these errors were encountered: