Having shared housing and living expenses with as many as six other people at a time, being able to track our expenses and account for them in a way that made sure everybody was paid what they were owed was essential. I set up an accounting system that let us reconcile after a period of time with a minimum of transactions. That is, you'd never have to give money to somebody who was just going to give it back or pass it on to somebody else - there would be at most one check to hand out per party, in total.
I called it The Magic Pot. It's a matter of changing slightly what you track so that instead of trying to keep all the relationships between each party in mind, which is n(n-1) relationships if you're counting each direction debt would flow, down to n*2 - your relationship to an imaginary central account. Sometimes adding another actor into the mix makes it easier. What you track is how much The Magic Pot owes you and how much everybody else owes The Magic Pot. At the end of a period, you can then sum up your transactions with The Magic Pot and arrive at a total for how much you owe or are owed, as can everybody else, free from the complex web of tracking that is the complete connected graph.
Imagine one party purchases toilet paper as a house resource. In straightforward terms, it's simple enough - divide the cost evenly, and everybody else pays the purchaser their share. In The Magic Pot terms, the purchaser logs that each person owes an even share of the cost in their columns, and then they also log the sum total of those into their own column. If somebody else buys milk, in straightforward terms you might have to receive toilet paper money and then hand back milk money. This is simple enough to imagine for a couple transactions, but if other people are paying for internets, electricity, and rent, it starts to be much harder to track without going through the pain of gathering everybody and replaying every transaction. With The Magic Pot, all you need to account for is how much everybody owes you for each purchase.