iishreya / cash-sttlement-project Goto Github PK
View Code? Open in Web Editor NEWThis project forked from shivangisachan20/cash-sttlement-project
In Splitwise Cashflow Minimization with help of heap , minimise number of transaction among n people. My project Splitwise Cashflow Minimization inspiration came from using Splitwise App in which keep track of your shared expenses and balances with housemates, trips, groups, friends, and family. For Example, if the following weighted directed graph represents some people and the arrows represent debts between them (Alice owes Bob $20 and Charlie $5, Bob owes Charlie $10, etc. How to pick the first person? To pick the first person, calculate the net amount for every person where net amount is obtained by subtracting all debts (amounts to pay) from all credits (amounts to be paid). Once net amount for every person is evaluated, find two persons with maximum and minimum net amounts. These two persons are the most creditors and debtors. The person with minimum of two is our first person to be settled and removed from list. Let the minimum of two amounts be x. We pay โxโ amount from the maximum debtor to maximum creditor and settle one person. If x is equal to the maximum debit, then maximum debtor is settled, else maximum creditor is settled.