Socket
Socket
Sign inDemoInstall

@datastructures/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

    @datastructures/graph

A minimal functional typed implementation of Graph 📈📉


Version published
Weekly downloads
1
Maintainers
1
Created
Weekly downloads
 

Readme

Source

@datastructures/graph 📈📉

Typed with TypeScript npm version

A minimal functional typed implementation of a graph. 🦄

A collection of vertices related by edges


Install

yarn add @datastructures/graph -D

Usage

import { graph, vertex } from '@datastructures/graph'
const chart = graph().addVertex('foo').addVertex('bar')
chart.addEdge('foo', 'bar')
const viewChart = chart.render()
// => { directed: false, vertices: [ { key: 'foo', ...}, { key: 'bar', ...} ], edges: ['foo-bar' ]}
const printChart = chart.print()

API

Vertex

A individual vertice

key: a string vertex identifier

siblings: an array of vertices

addSibling: a methode for adding siblings to a vertex

ex: const item = vertex('foo').addSibling('bar')

Methods

addVertex: adds a vertex to the graph

ex: const chart = graph().addVertex('foo')

addEdge: adds an edge to the Graph

ex: const chart = graph().addVertex('foo').addEdge('bar').addEdge('foo', 'bar')

render: renders the graph

ex: const chart = graph().addVertex('foo').addEdge('bar').addEdge('foo', 'bar').render()

print: renders a string output of the graph

ex: const chart = graph().addVertex('foo').addEdge('bar').addEdge('foo', 'bar').print()


Data Structures 🦄

Basic. Functional. Typed. Data Structures.

Functional typed data structures offering structure clarity and simplicity.


View other data structures.

Keywords

FAQs

Last updated on 02 Jul 2022

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