New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

graphreduce

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphreduce

construct graphs as reduce function

latest
Source
npmnpm
Version
3.0.4
Version published
Maintainers
1
Created
Source

graphreduce

var G = require('graphmitter')
var g = {}

// create edges
G.edge(g, 1, 2)
G.edge(g, 2, 3)
G.edge(g, 3, 4)

// delete an edge
G.del(g, 3, 4)

// iterate each node
G.each(g, console.log)
// => 1 { edges: { '2': true } }
// => 2 { edges: { '3': true } }
// => 3 { edges: { '2': true } }
// => 4 { edges: {} }

// g is a plain old javascript object
g /* =>
{ '1': { '2': true },
  '2': { '3': true },
  '3': {},
  '4': {} }
*/


// rank the connectedness of nodes using a pagerank derivative
G.rank(g) /* =>
{ '1': 0.037500000000000006,
  '2': 0.25,
  '3': 0.25,
  '4': 0.037500000000000006 }
*/
G.edge(g, 3, 2)
G.rank(g) /* =>
{ '1': 0.037500000000000006,
  '2': 0.4625,
  '3': 0.25,
  '4': 0.037500000000000006 }
*/

// helper to generate a random graph
var _g = G.random(100, 100) // 100 nodes, 100 edges

License

MIT

FAQs

Package last updated on 27 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts