GithubHelp home page GithubHelp logo

custom-dag's Introduction

custom-dag

Provides methods for topological analysis of directed acyclic graphs, i.e. DAG analysis.

How to use

 use custom_dag::{
    Node,
    collitions::CollidingNode,
    Dag,
 };
 let node_a = Node::new(0,None,None);
 let node_b = Node::new(1,Some(0),None);
 let node_c = Node::new(2,None,Some(0));
 let node_d = Node::new(3,Some(0), Some(1));
 let node_e = Node::new(4,Some(2), Some(1));
 let node_f = Node::new(5,Some(3), Some(4));
 let node_list = [node_a, node_b, node_c, node_d, node_e, node_f];
 let ordering = Topology::sort(&node_list).unwrap().unwrap();
 assert!(ordering.len() > 0);
 let mut dag = Dag::new();
 for node in ordering {
     dag.insert(node);
 };
 assert!(dag.is_safe());

Build

cargo build --release

Run tests

cargo test --release

Build documentation

cargo doc

Examples

Examples are provided in the examples directory. There is also a main example that reads a text file and constructs a dag from the following format. Database template:

N # integer, number of nodes
L R # integers describing a node, L and R = Left and Right parent
L R # integers describing a node, L and R = Left and Right parent, etc...
L R # integers describing a node, L and R = Left and Right parent, etc...

It can be run with the command:

cargo run --release -- examples/dag-stats/data/dag.txt

AVG SHORT DAG DEPTH: 1.3333334
AVG LONG DAG DEPTH: 2
NUMBER OF ALL PATHS 24
AVG NODES PER PATH 3.5416667

wasm-binding example

There is a wasm-binding example for binding the topological analysis methods into typescript code. check ./examples/wasm-binding

custom-dag's People

Contributors

labormedia avatar

Watchers

 avatar

Forkers

onedge-network

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.