I'm working on a game where there are several different entities represented by nodes. Each node has a starting balance, and directed edges show where money is owed from one account to another.
One problem I'm trying to figure out is which order to process transactions in, take this example below:
If you start by processing node 'B', because there is no balance, the \$30 is not transferred to node C. Node A only receives \$20 instead of \$50, bringing the balance to \$50. 'A' can't afford to pay both D and B, so depending on which is paid first the result is different. If D is paid first the balance goes up to \$80. The remaining \$20 goes to B. Then B also receives \$80. The final graph is:
Is there an algorithm for solving situations like this? Is this related to network flow graphs or is that something different? I'm trying to figure out what problem class this is.