Link Search Menu Expand Document


graphology is a robust & multipurpose Graph object for JavaScript and TypeScript.

It aims at supporting various kinds of graphs with the same unified interface.

A graphology graph can therefore be directed, undirected or mixed, allow self-loops or not, and can be simple or support parallel edges.

Along with this Graph object, one will also find a comprehensive standard library full of graph theory algorithms and common utilities such as graph generators, layouts, traversals etc.

Finally, graphology graphs are able to emit a wide variety of events, which makes them ideal to build interactive renderers for the browser. It is for instance used by sigma.js as its data backend.


To install graphology using npm, run the following command:

npm install graphology

The source repository can be found on this github repository, where you will be able to find standalone builds in the releases for older JavaScript configurations.

Note that graphology also exports type declaration that are installed along using peer dependencies so it can be used with TypeScript out of the box.

If your version of npm is a bit old, you may need to install graphology-types yourself if the peer dependency resolution is not made for you already:

npm install graphology-types

It can also be useful to pin graphology-types version in your package.json to avoid resolution issues sometimes.

Quick Start

import Graph from 'graphology';

const graph = new Graph();

// Adding some nodes

// Adding an edge
graph.addEdge('John', 'Martha');

// Displaying useful information about your graph
console.log('Number of nodes', graph.order);
console.log('Number of edges', graph.size);

// Iterating over nodes
graph.forEachNode(node => {

How to cite


graphology is published on Zenodo as

You can cite it thusly:

Guillaume Plique. (2021). Graphology, a robust and multipurpose Graph object for JavaScript. Zenodo.


A complete changelog can be found here.

Implementing graphology

There are many ways to implement a Graph data structure and even if graphology chose to optimize for most common use cases, you might need a more specialized implementation yourself.

In this case, know that graphology can be re-implemented completely without losing the benefit of being able to use its standard library.

For more information, be sure to read this section of the documentation.


This documentation has been built with Jekyll using the Just the Docs theme.