npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

graphology-dot

v0.0.1

Published

DOT parser & writer for graphology.

Readme

Graphology DOT Utilities

Graphviz DOT parser & writer for graphology.

For more information about the Graphviz DOT file format, see the DOT Language documentation.

Installation

npm install graphology-dot

Usage

Parser

The parser takes a graphology constructor and a DOT string, returning a graphology graph instance.

var Graph = require('graphology');

// Node
var dot = require('graphology-dot');
// Browser
var dot = require('graphology-dot/browser');

// Reading a string
var graph = dot.parse(Graph, string);

// Passing options
var graph = dot.parse(Graph, string, {addMissingNodes: true});

Arguments

  • constructor GraphClass: graphology constructor to use.
  • source string: DOT string to parse.
  • options ?object: parsing options:
    • addMissingNodes ?boolean [false]: whether to add missing nodes referenced in edge statements. In DOT, nodes are commonly defined implicitly through edges, so missing nodes are always added automatically regardless of this option.

Supported DOT Features

  • graph / digraph / strict graph / strict digraph declarations
  • Node statements with attributes: nodeID [key=value, ...]
  • Edge statements: n1 -- n2 (undirected) / n1 -> n2 (directed)
  • Edge chains: a -> b -> c -> d
  • Attribute statements for defaults: graph [...], node [...], edge [...]
  • Subgraphs (named and anonymous): subgraph S { ... } / { ... }
  • Comments: // line, /* block */, # line
  • Quoted node IDs and attribute values: "node name" [label="A Label"]
  • Numeric node IDs: 1, 42
  • Port/compass syntax: node:port, node:port:compass
  • HTML-like labels: <b>bold</b>

Attribute Type Inference

Attribute values are automatically cast to the appropriate JavaScript type:

  • true / falseboolean
  • 42, 3.14, -1number
  • "hello"string
  • barewordstring
  • Bare key without value (e.g. [active]) → true

Writer

The writer takes a graphology instance and outputs a DOT string.

// Node
var dot = require('graphology-dot');
// Browser
var dot = require('graphology-dot/browser');

// Writing the graph
var dotString = dot.write(graph);

// Using custom formatting for nodes & edges
var dotString = dot.write(graph, {
  formatNode: function (key, attributes) {
    return {
      label: attributes.label,
      color: attributes.color,
      size: attributes.size
    };
  },
  formatEdge: function (key, attributes) {
    return {
      weight: attributes.weight,
      active: attributes.active
    };
  }
});

Arguments

  • graph Graph: graphology instance to write.
  • options ?object: Options:
    • formatNode ?function: function receiving (key, attributes) and returning the node's data to write. Defaults to writing all attributes.
    • formatEdge ?function: function receiving (key, attributes) and returning the edge's data to write. Defaults to writing all attributes.

Writer Behavior

  • Undirected/mixed graphs use the graph keyword; directed graphs use digraph.
  • The graph's id attribute becomes the graph name: graph G { ... }.
  • Other graph-level attributes are written as graph [key=value, ...].
  • Attribute values are formatted according to their JavaScript type:
    • Booleans → true / false
    • Numbers → unquoted literal (42, 3.14)
    • Simple string identifiers → unquoted (red)
    • Strings with special characters → quoted ("hello world")