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

graphlib-json-graph

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphlib-json-graph

Converts json-graph definitions into graphlib graphs.

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
2
-71.43%
Maintainers
1
Weekly downloads
 
Created
Source

graphlib-json-graph

Converts json-graph definitions into graphlib graphs.

npm install --save graphlib-json-graph

Example

var toGraph = require("graphlib-json-graph");

var graphDefinition = {
    graph: {
        label: "Example graph",
        nodes: [{
            id: "1"
        }, {
            id: "2"
        }],
        edges: [{
            id: "e1",
            directed: true,
            source: "1",
            target: "2"
        }]
    }
};

var graph = toGraph(graphDefinition);

graph.nodes(); // ["1", "2"]
graph.edges(); // {v: "1", w: "2"}

API

The module exports one function: toGraph(graphDefinition).

graphDefinition is supposed to be an object that conforms with the json graph specification.

The function returns either one, or a list of graphlib graphs.

The distinction is based on whether you have a graphs property or a graph property.

Notes

  • The graph is set to be a multigraph by default to support multiple edges that point to the same nodes
  • If you do have multiple edges that connect the same nodes, you must provide an id property for them so that you can differentiate them by name
  • the labels for the nodes and edges in the graph are set to the objects in the definition JSON

Testing

Is based on mochajs

  • Clone the repo
  • npm install
  • npm test

Contributing

Feel free to raise an issue or submit a pull request

In terms of styling, please use tabs for indentation

Keywords

json

FAQs

Package last updated on 08 Jul 2015

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