Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-graphviz

Package Overview
Dependencies
Maintainers
1
Versions
181
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-graphviz

Graphviz library for TypeScript.

  • 1.8.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is ts-graphviz?

The ts-graphviz package is a TypeScript library for creating and manipulating Graphviz graphs. It provides a fluent API to build and render graphs programmatically, making it easier to generate complex diagrams and visualizations.

What are ts-graphviz's main functionalities?

Creating a Graph

This feature allows you to create a directed graph with nodes and edges. The code sample demonstrates how to create a simple graph with two nodes, 'A' and 'B', and an edge from 'A' to 'B'.

const { digraph } = require('ts-graphviz');
const g = digraph('G', (g) => {
  g.node('A');
  g.node('B');
  g.edge(['A', 'B']);
});
console.log(g.toDot());

Customizing Nodes and Edges

This feature allows you to customize the appearance of nodes and edges. The code sample shows how to set the color of a node, change the shape of another node, and add a label to an edge.

const { digraph } = require('ts-graphviz');
const g = digraph('G', (g) => {
  g.node('A', { color: 'red' });
  g.node('B', { shape: 'box' });
  g.edge(['A', 'B'], { label: 'A to B' });
});
console.log(g.toDot());

Subgraphs

This feature allows you to create subgraphs within a graph. The code sample demonstrates how to create two subgraphs, each with its own nodes and edges, and then connect nodes from different subgraphs.

const { digraph, subgraph } = require('ts-graphviz');
const g = digraph('G', (g) => {
  g.subgraph('cluster_0', (s) => {
    s.node('A');
    s.node('B');
    s.edge(['A', 'B']);
  });
  g.subgraph('cluster_1', (s) => {
    s.node('C');
    s.node('D');
    s.edge(['C', 'D']);
  });
  g.edge(['A', 'C']);
});
console.log(g.toDot());

Other packages similar to ts-graphviz

Keywords

FAQs

Package last updated on 06 Jun 2023

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc