You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@types/dagre

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/dagre

TypeScript definitions for dagre


Version published
Weekly downloads
191K
decreased by-18.03%
Maintainers
1
Created
Weekly downloads
 

Package description

What is @types/dagre?

@types/dagre provides TypeScript type definitions for the dagre library, which is used for graph layout. Dagre helps in arranging nodes and edges in a directed graph, making it easier to visualize complex relationships.

What are @types/dagre's main functionalities?

Graph Creation

This feature allows you to create a new graph, add nodes, and define edges between them. The code sample demonstrates how to initialize a graph, set default properties, and add nodes and edges.

const dagre = require('dagre');
const g = new dagre.graphlib.Graph();
g.setGraph({});
g.setDefaultEdgeLabel(() => ({}));
g.setNode('a', { label: 'Node A', width: 50, height: 50 });
g.setNode('b', { label: 'Node B', width: 50, height: 50 });
g.setEdge('a', 'b');

Graph Layout

This feature allows you to compute the layout of the graph. The code sample shows how to use the `layout` function to calculate the positions of the nodes.

const dagre = require('dagre');
const g = new dagre.graphlib.Graph();
g.setGraph({});
g.setDefaultEdgeLabel(() => ({}));
g.setNode('a', { label: 'Node A', width: 50, height: 50 });
g.setNode('b', { label: 'Node B', width: 50, height: 50 });
g.setEdge('a', 'b');
dagre.layout(g);
console.log(g.node('a')); // { label: 'Node A', width: 50, height: 50, x: 25, y: 25 }
console.log(g.node('b')); // { label: 'Node B', width: 50, height: 50, x: 75, y: 75 }

Custom Node and Edge Attributes

This feature allows you to add custom attributes to nodes and edges. The code sample demonstrates how to set and retrieve custom attributes for nodes and edges.

const dagre = require('dagre');
const g = new dagre.graphlib.Graph();
g.setGraph({});
g.setDefaultEdgeLabel(() => ({}));
g.setNode('a', { label: 'Node A', width: 50, height: 50, customAttr: 'customValue' });
g.setNode('b', { label: 'Node B', width: 50, height: 50 });
g.setEdge('a', 'b', { customEdgeAttr: 'edgeValue' });
dagre.layout(g);
console.log(g.node('a').customAttr); // 'customValue'
console.log(g.edge('a', 'b').customEdgeAttr); // 'edgeValue'

Other packages similar to @types/dagre

Readme

Source

Installation

npm install --save @types/dagre

Summary

This package contains type definitions for dagre (https://github.com/dagrejs/dagre).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/dagre.

Additional Details

  • Last updated: Mon, 06 Nov 2023 22:41:05 GMT
  • Dependencies: none

Credits

These definitions were written by Qinfeng Chen, Pete Vilter, David Newell, and Graham Lea.

FAQs

Package last updated on 07 Nov 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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc