Socket
Socket
Sign inDemoInstall

@pipepack/graph

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @pipepack/graph

A graph data structure with pipepack related algorithm.


Version published
Weekly downloads
7
Maintainers
1
Install size
18.8 kB
Created
Weekly downloads
 

Readme

Source

graph

Build Status Coverage Status Package Dependency Package DevDependency

A graph data structure with pipepack related algorithm.

Installing

This library is distributed only via NPM.

# npm
npm install @pipepack/graph;
# yarn
yarn add @pipepack/graph;

Then, use like below:

// esm
import { Graph } from '@pipepack/graph';
// commonjs
const { Graph } = require('@pipepack/graph');

Serialization

Serializes the graph with declaration below:

type NodeID = string;
type EdgeID = string;
type EdgeWeight = string | number;

interface GraphNode {
  id: NodeID;
}

interface GraphEdge {
  source: NodeID;
  target: NodeID;
  weight?: EdgeWeight;
}

interface Serialized {
  nodes: GraphNode[];
  edges: GraphEdge[];
}
const graph = new Graph();

graph.addEdge('a', 'b');
graph.addEdge('b', 'c');
{
  "nodes": [{ "id": "a" }, { "id": "b" }, { "id": "c" }],
  "links": [
    { "source": "a", "target": "b", "weight": 1 },
    { "source": "b", "target": "c", "weight": 1 }
  ]
}

Licence

MIT

Keywords

FAQs

Last updated on 05 Dec 2020

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc