How : Changed the task to a full fledged Directed Acyclic Graph, any amount of edges still no weights as I don't think they are needed in this context.
- Node Count: 10
- Edge Count: 9
- Count of source Nodes
- Count of leaf Nodes
- Average Depth from Node 0
- Avarage Depth from all Source Nodes
- Avarage In-references per Node
- Average Nodes per depth
- DAG density
- Average Path length/distance between nodes
"database" format is more complex for this as I felt it was lackluster from a developers perspective.
First line is still node count after that lines are related to the nodes themself, while the numbers are edge targets. Example:
5
1 2
2 3
4 5
So we have 5 nodes, first one is Node(0) with edges 0->1 and 0->2 and so on. For nodes that dont have outgoing edges the lines and empty or non existing as the Graph is constructed based on the edges and will create nodes if there is no node which was targeted. You may have empty lines start, middle,end. It does not matter.
Why : I felt like a full fledged DAG will be more interesting as there may be more issues in porting to WASM, and those are chances to show off.
Firstly you will need Rust https://doc.rust-lang.org/cargo/getting-started/installation.html Then lets get the source after you have setup Rust and Cargo
git clone https://github.com/Apokalip/IOTA_DAG.git
We have 2 folders: dag_generator : generates DAG-s for testing with a number of nodes and targeted density(tries to get close to it) dag_wasm : the package and demo itself
Move to the dag_generator folder
cd dag_generator
Generate a dag file
cargo run -- -n 30 -d 0.3
Where -n / --nodes are the number of wanted nodes -d / --density is the targeted density After running you should have a DAG_30nodes_0.3density.txt file. The name will always be related to the inputs.
Lets use the previously generated DAG file in (How to create a DAG file for testing)
cd dag_wasm
cargo update
cargo run -- DAG_30nodes_0.3density.txt
You should get an output with some statistics about the DAG
Run these in order. Install npm if you dont have it.
After the first build, npm run build
and npm start
should rebuild the Rust Wasm package automatically
cd dag_wasm
cargo install wasm-pack
wasm-pack --target web --features wasm
npm install
npm build
npm start
After running you should see a page on localhost and someport. Either your IDE will auto open it or look at the terminal for something like
<i> [webpack-dev-server] Loopback: http://localhost:8089/
This is the page you will see. Paste your DAG "database" context in the field and click load. The context will be converted to a WASM graph and you will get statistics on the right.