This project provides a system to parse transaction data and compute various graph-based statistics on the data.
Given a list of transactions with their unique identifiers, two reference transactions (left & right), and a timestamp, the system constructs a graph in memory and calculates several statistics, including:
- Average depth of the Directed Acyclic Graph (DAG).
- Average number of transactions per depth.
- Average number of out-references per node.
- Additional statistics like the number of leaf nodes, topological order of transactions, etc.
- Bipartite Graph: The constructed graph is assumed to be bipartite. However, most of our calculations work even if it's not.
- Timestamp: Each node in the graph has an associated timestamp. For now, it's used for operations like ordering the transactions, validating ... etc.
- Unique IDs: Each node in the graph has a unique identifier. This is used to identify nodes in the graph and to reference them in the input data, the IDs are assumed to be integers and start from 0.
- Node.js and TypeScript installed.
- Ensure you have the necessary dependencies installed via
yarn install
.
- Place your transaction data in a
.txt
file with the structure specified below. Examples are provided in thetest/files
directory. - Run the main program with the path to your data file as an argument.
For example:
yarn start test/files/database_original.txt
N
L R T
...
Where:
N
is the number of nodes (transactions).L
andR
are the left and right parent node IDs, respectively.T
is the timestamp.
Examples are provided in the test/files
directory.
Run tests using the following command:
yarn test
Get test coverage using the following command:
yarn test:coverage