Skip to content

Algorithm that takes in a directed graph of n nodes, where the edges are how much one node "owes" to another. The algorithm prunes the graph until there are the minimum number of transactions such that every node gets the amount they are "owed".

License

Notifications You must be signed in to change notification settings

RodAli/min-flow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

min-flow

Description

Algorithm that takes in a directed graph of n nodes, where the edges are how much one node "owes" to another. The algorithm prunes the graph until there are the minimum number of transactions such that every node gets the amount they are "owed".

The most common application for this script is when a group of people owe eachother money. Take the example below:

my image

The script will reduce the number of transcations, such that everyone gets the amount of money that they are owed:

my image

This assumes that the currency is universal.

How to run

After cloning the repo, you can run the script by simply running main.py

python main.py

The program will prompt you for an input csv file. An example of the format of the csv is given in input.csv:

Adam,Bob,15
Bob,Adam,6
Adam,Carl,12
Carl,Adam,3
Bob,Dave,12
Adam,Earl,10
Earl,Bob,8
Earl,Carl,15
Dave,Earl,12

About

Algorithm that takes in a directed graph of n nodes, where the edges are how much one node "owes" to another. The algorithm prunes the graph until there are the minimum number of transactions such that every node gets the amount they are "owed".

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages