Socket
Book a DemoInstallSign in
Socket

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

@datastructures/graph

A minimal functional typed implementation of Graph 📈📉

latest
Source
npmnpm
Version
0.0.1
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
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

graph data structure

FAQs

Package last updated on 02 Jul 2022

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