Cash Flow Algorithm Project Final Report
Cash Flow Algorithm Project Final Report
Submitted by:
NAME REG NO
E SIVASIDHARTH 19BEC0721
R S NAVIN 19BEC0224
1
DECLARATION
2
S.No Title Pg No.
3
INTRODUCTION
Finding the cheapest possible way of sending a certain amount of flow through
a flow network There may be situation where a person may give or get money
from someone and that person may indeed be giving or getting money from
some other let look at it visually without simplification
For example, if the following weighted directed graph represents some people
and the arrows represent debts between them (Alice owes Bob Rs.20 and
Charlie Rs.5, Bob owes Charlie Rs.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
4
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.
There’s no sense in Rs.10 making its way from Alice to Bob and then from Bob
to Charlie if Alice could just give it to Charlie directly.
The goal, then, in the general case is to take a debt graph and simplify it (i.e.
produce a new graph with the same nodes but different edges).
5
ALGORITHM
THE ALGORITHM IS THAT WE TAKE A PERSON AND CALCULATE
HIS NET AMOUNT (CREDIT-DEBIT) AND ADD IT IN A MAX-HEAP
AND WE TAKE THE PERSON WITH HIGHEST DEBIT i.e(the last element
in heap) AND THE PERSON WITH HIGHEST CREDIT AND TRY TO
SETTLE THEM AND IF SETTLED WE POP THEM OR WE FUTHER
MOVE ON SETTLING IN SAME WAY AND ATLAST WE WILL GET
SHORT PATH CASH FLOW WE USE GRAPH TO REPRESENT THE
DATA FLOW
6
PROGRAMMING LANGUAGE
JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled
programming language with first-class functions. While it is most well-known as
the scripting language for Web pages, many non-browser environments also use
it, such as Node.js, Apache CouchDB and Adobe Acrobat. JavaScript is
a prototype-based, multi-paradigm, single-threaded, dynamic language,
supporting object-oriented, imperative, and declarative (e.g. functional
programming) styles.
HTML (HyperText Markup Language) is the most basic building block of the
Web. It defines the meaning and structure of web content. Other technologies
besides HTML are generally used to describe a web page's
appearance/presentation (CSS) or functionality/behavior (JavaScript).
"Hypertext" refers to links that connect web pages to one another, either within a
single website or between websites. Links are a fundamental aspect of the Web.
By uploading content to the Internet and linking it to pages created by other
people, you become an active participant in the World Wide Web.
Cascading Style Sheets (CSS) is a style sheet language used for describing
the presentation of a document written in a markup language such
as HTML.[1] CSS is a cornerstone technology of the World Wide Web,
alongside HTML and JavaScript.
CSS is designed to enable the separation of presentation and content,
including layout, colors, and fonts. This separation can improve
content accessibility, provide more flexibility and control in the specification of
presentation characteristics, enable multiple web pages to share formatting by
specifying the relevant CSS in a separate .css file which reduces complexity and
repetition in the structural content as well as enabling the .css file to
be cached to improve the page load speed between the pages that share the file
and its formatting.
7
CODE
We have used React.js framework to build the project
Implementation of algorithm :
export default (allmembers, totalMembers, totalPrice) => {
a.splice(0, 1);
a.splice(a.length - 1, 1);
if (debit !== 0) {
let val = {
8
name: dname,
cost: debit,
};
a.push(val);
}
if (credit !== 0) {
let val = {
name: cname,
cost: credit,
};
a.push(val);
}
a = a.sort((a, b) => {
return b.cost - a.cost;
});
cnt += 1;
}
return {
count: cnt,
transactions: graph,
};
};
9
);
};
Input.js
import React, { useState } from "react";
10
className="mb"
id="roomate"
label="Name"
variant="outlined"
value={newMember}
onChange={(e) => {
editNewMember(e.target.value);
}}
/>
<Button
className="mb"
type="submit"
variant="contained"
color="primary"
onClick={handleAddMember}
>
ADD MEMBER
</Button>
</div>
</form>
<h2 className="head">Add New Transaction</h2>
<form className={classes.root} noValidate autoComplete="off">
<div className="flex-col">
<TextField
id="item"
label="Item Name"
variant="outlined"
value={item}
onChange={(e) => {
editItem(e.target.value);
}}
/>
<FormControl variant="outlined">
<InputLabel variant="filled" id="person">
Bought By
</InputLabel>
<Select
labelId="person"
id="person"
value={member}
onChange={(e) => {
editMember(e.target.value);
}}
>
{menuList}
</Select>
</FormControl>
<TextField
11
id="Price"
label=""
variant="outlined"
value={price}
onChange={(e) => {
editPrice(e.target.value);
}}
/>
<Button
className="btn "
type="submit"
variant="contained"
color="primary"
onClick={handleAddItem}
>
ADD ITEM
</Button>
</div>
</form>
</div>
);
};
Header.js
import React from "react";
import "./header.css";
12
const Header = () => {
return (
<div className="Title">
<header>
<h1>SHORTEST PATH CASH FLOW ALGORITHM</h1>
</header>
</div>
);
};
Feedback.js
import React from "react";
import { connect } from "react-redux";
import Card from "@material-ui/core/Card";
import CardContent from "@material-ui/core/CardContent";
13
return {
allItems: allItems,
};
};
Solution.js
import React from "react";
import { connect } from "react-redux";
import brain from "../brain";
import Card from "@material-ui/core/Card";
import CardContent from "@material-ui/core/CardContent";
14
return (
<div>
<h2 className="head">Shortest Cash Flow</h2>
{count ? <p>Total of {count} transactions</p> : null}
<div className="flex-col">{count ? final : def}</div>
</div>
);
};
StateManagement:Redux
15
OUTPUT
16
17
REFERENCE
• https://www.google.com/
• https://www.wikipedia.org/
• https://link.springer.com/article/10.1007/s12205-015-0588-5
• https://medium.com/@soumyasethy/shortest-path-or-minimum-cash-
flow-algorithm-using-java-5848d4148a76
• https://www.semanticscholar.org/paper/The-algorithm-of-cash-flow-
forecasting-in-planning-Kim-
Park/2fdc14451937cf1f4d7c4a44c89c2a52cd5d1645
18