# IOTA Foundation Hiring Task ## Objective You are provided with a list of nodes that have been reduced to: - their unique identifier: `id` - two nodes that they reference:`left` and `right` Your task is to parse this list into a Directed Acyclic Graph and provide statistics such as: - Average depth of the DAG (assume that the graph has a single point of origin ID=1 and depth is the shortest path to it) - Average number of nodes per depth (not including depth 0) - Average number of in-references per node - Be creative, find some more statistics that you think would be interesting to have ## Input & Output In addition to being able to manually create a DAG, add nodes and set references, you should be able to instantiate a DAG from a plain text file, with a structure as follows: - Line 1: `N`, the number of nodes in the database - Lines 2 through `N + 1`: the node data, where each node consists of the `id`s of its `left` and `right` parents - Node `id` `1` is the unique origin of all nodes - The `id` of each node in the database is its line number ``` # Database template 1 N # integer, number of nodes 2 L R # integers describing a node, L and R = Left and Right parent node ids 3 . . # 4 . . 5 . . ``` The program is expected to be run and output to the console as follows: ``` $ ./dag database.txt > AVG DAG DEPTH: ??? > AVG NODES PER DEPTH: ??? > AVG IN-REF: ??? > <YOUR STAT>: ??? > <YOUR STAT>: ??? > <YOUR STAT>: ??? ... ``` ## Example database.txt: ``` 5 1 1 1 2 2 2 3 6 3 3 ``` Produces the graph: ![image](https://hackmd.io/_uploads/rJYMgyg56.png) Running and output: ``` $ ./dag database.txt > AVG DAG DEPTH: 1.33 > AVG NODES PER DEPTH: 2.5 > AVG REF: 1.667 ``` ## Delivery Your project: - Must be in Rust - Must be done on your own - Should showcase your Rust abilities and attention to details - Be commented to explain decisions - Should include tests and documentation - Can expand beyond our requirements - Be sent to us by email within a week, let us know if you need more time - Must not be featured publicly on any source code platform (Github, Gitlab, ...) Feel free to contact thibault@iota.org if you have any questions.