Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@ts-graphviz/core
Advanced tools
@ts-graphviz/core is a TypeScript library for creating and manipulating Graphviz graphs. It provides a programmatic way to build and render graphs using the Graphviz DOT language.
Creating a Graph
This feature allows you to create a directed graph, add nodes, and create edges between them. The `toDot` method converts the graph to DOT format.
const { digraph } = require('@ts-graphviz/core');
const g = digraph('G');
g.node('A');
g.node('B');
g.edge(['A', 'B']);
console.log(g.toDot());
Subgraphs
This feature allows you to create subgraphs within a main graph. Subgraphs can be used to group nodes together.
const { digraph, subgraph } = require('@ts-graphviz/core');
const g = digraph('G');
const s = subgraph('cluster_0');
s.node('A');
s.node('B');
g.subgraph(s);
console.log(g.toDot());
Graph Attributes
This feature allows you to set attributes for the graph, such as the direction of the graph layout.
const { digraph } = require('@ts-graphviz/core');
const g = digraph('G', { rankdir: 'LR' });
g.node('A');
g.node('B');
g.edge(['A', 'B']);
console.log(g.toDot());
The 'graphviz' package is a Node.js wrapper for the Graphviz command-line tool. It allows you to generate DOT files and render them to various formats like PNG, PDF, etc. Unlike @ts-graphviz/core, it relies on the Graphviz installation on your system.
The 'viz.js' package is a JavaScript port of Graphviz that runs in the browser and Node.js. It allows you to render DOT files directly in the browser without needing a Graphviz installation. It is more focused on rendering rather than programmatic graph creation.
The 'd3-graphviz' package integrates Graphviz with D3.js, allowing you to create and manipulate graphs using D3's data-driven approach. It is more suitable for dynamic and interactive visualizations compared to @ts-graphviz/core.
It is part of the ts-graphviz library, which is split into modular packages to improve maintainability, flexibility, and ease of use.
This package contains the core implementation of models and functions provided to users for the ts-graphviz library.
Import the necessary classes and functions from the @ts-graphviz/core package:
import { Graph, Node, Edge } from '@ts-graphviz/core';
Use the imported items in your project to create and manipulate DOT language elements:
const graph = new Graph('G');
const nodeA = new Node('A', { label: 'Node A' });
const nodeB = new Node('B', { label: 'Node B' });
const edge = new Edge([nodeA, nodeB], { label: 'A -> B' });
graph.addNode(nodeA);
graph.addNode(nodeB);
graph.addEdge(edge);
console.log(graph.toDot());
For more examples and usage details, please refer to the ts-graphviz documentation.
Contributions to the ts-graphviz project are welcome.
Please refer to the main ts-graphviz repository for guidelines on how to contribute.
This package is released under the MIT License.
FAQs
Graphviz Models for Object-Oriented Programming
We found that @ts-graphviz/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.