Inside Contri's Smart Debt Engine

How computer science and graph theory eliminate circular payments so your group settles in up to 83% fewer transfers.

The Problem We Solve: In a group of 5 friends on a road trip, 15 different expenses can easily generate 10 to 12 overlapping, circular debts. Contri computes the minimum cash flow graph so everyone is squared away in just 2 or 3 direct payments.

What is Circular Debt?

Imagine three flatmates: Aman, Rohan, and Vikram:

  • Aman pays ₹600 for groceries (Rohan owes Aman ₹200, Vikram owes Aman ₹200).
  • Rohan pays ₹900 for Wi-Fi and electricity (Aman owes Rohan ₹300, Vikram owes Rohan ₹300).
  • Vikram pays ₹300 for cleaning supplies (Aman owes Vikram ₹100, Rohan owes Vikram ₹100).

Without simplification, this requires 6 separate bank transfers back and forth. Aman sends money to Rohan, Rohan sends money to Vikram, and Vikram sends money to Aman. It’s dizzying, fees add up, and people forget.

How Contri's Algorithm Calculates the Shortest Path

Contri ignores the messy web of individual micro-debts and looks only at the Net Balance of each individual:

Net Balance = (Total Money Paid) - (Total Fair Share Consumed)

Using our previous example:

  • Aman: Paid ₹600, consumed ₹600. Net = ₹0 (Fully settled!).
  • Rohan: Paid ₹900, consumed ₹600. Net = +₹300 (Owed money).
  • Vikram: Paid ₹300, consumed ₹600. Net = -₹300 (Owes money).

Instead of 6 transactions, Contri's algorithm produces a single, elegant instruction:

Single Transfer Solution: Vikram pays Rohan ₹300. Done. Aman does nothing. 6 payments become 1.

The Mathematics: Solving the Minimum Cash Flow Problem

Mathematically, this is modeled as a directed debt graph. Finding the absolute minimal number of edges in a debt network is related to the Subset Sum problem (which is NP-complete).

Contri runs an optimized Greedy Flow Network Matching Algorithm in real-time on your mobile device:

  1. It partitions group members into Creditors (positive net balance) and Debtors (negative net balance).
  2. It sorts both lists by absolute balance magnitude.
  3. It greedily matches the maximum debtor with the maximum creditor, transferring the minimum of the two amounts.
  4. The matched party is reduced to zero balance and removed from the active set.
  5. The loop terminates when all balances reach zero.

This reduces typical group settlement overhead from O(N²) chaotic payment notifications down to at most N - 1 clean transfers.

Why Other Apps Lock This Behind $4.99/mo Paywalls

Many older apps (like Splitwise) treat debt simplification as an expensive "Pro" luxury. When you don't pay their monthly fee, they intentionally leave debts complicated and unsimplified to incentivize upgrades.

At Contri, we believe math should be free. Group friendships shouldn't suffer from avoidable financial confusion. Contri provides full, unrestricted debt simplification on every group, completely free, with zero ads.