Code Monkey home page Code Monkey logo

random-dag's Introduction

random-dag

Create a random Directed Acyclic Graph as a stream or as a graphlib object.

npm install random-dag

build status

CLI

$ npm install -g random-dag
$ random-dag --max_per_rank=5 --max_ranks=100 --probability=.5
{ from: 0, to: 3 }
{ from: 0, to: 4 }
{ from: 2, to: 3 }
{ from: 2, to: 4 }
{ from: 2, to: 10 }
{ from: 2, to: 11 }
etc...

API

dag.stream(opts)

var dag = require('random-dag')
var opts = {
  max_per_rank: 5, // how 'fat' the DAG should be
  min_per_rank: 1,
  max_ranks: 3, // how 'tall' the DAG should be
  min_ranks: 5,
  probability: 0.3 // chance of having an edge
}
var stream = dag.stream(opts)
stream.on('data', function (edge) {
  // e.g, an edge from node with index '0' and index '1'.
  // {from: 0, to: 1}
})

dag.graphlib(opts, cb)

Can provide optional options as a first argument, same as above stream.

var graphlib = require('graphlib')
var dag = require('random-dag')
dag.graphlib(function (err, g) {
  // g is a graphlib.Graph object
  console.log(graphlib.alg.isAcyclic(g)) // true
})

License

MIT

random-dag's People

Contributors

okdistribute avatar

Stargazers

 avatar Asbjorn Enge avatar Fabricio Konell avatar Hans Kristian Flaatten avatar jiangplus avatar  avatar Ivo Georgiev avatar

Watchers

Max avatar Mathias Buus avatar  avatar James Cloos avatar

Forkers

flipdav8

random-dag's Issues

Use https:// for repository link

In package.json, using git+https as the protocol means the link on npm.org doesn't just take you to the webpage. Since you can clone directly from a URI with the https protocol also works, it would be nice to change to just https.

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.