cytoscape vs graphlib vs graphology vs vis-network
Graph Visualization and Manipulation Libraries
cytoscapegraphlibgraphologyvis-networkSimilar Packages:
Graph Visualization and Manipulation Libraries

Graph visualization and manipulation libraries in JavaScript provide tools for creating, displaying, and interacting with graph data structures (nodes and edges) in web applications. These libraries offer features like rendering graphs, performing layout algorithms, handling user interactions (e.g., dragging nodes, clicking edges), and manipulating graph data programmatically. They are widely used in data visualization, social network analysis, organizational charts, and any application that requires representing relationships between entities. Each library has its strengths, such as performance, ease of use, customization, and support for large datasets, making them suitable for different use cases.

Npm Package Weekly Downloads Trend
3 Years
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
cytoscape3,284,18910,8325.67 MB266 months agoMIT
graphlib2,704,8051,715-286 years agoMIT
graphology774,2031,5722.73 MB84a year agoMIT
vis-network446,1773,51082.9 MB3425 months ago(Apache-2.0 OR MIT)
Feature Comparison: cytoscape vs graphlib vs graphology vs vis-network

Graph Manipulation

  • cytoscape:

    cytoscape provides extensive graph manipulation capabilities, including adding/removing nodes and edges, updating attributes, and performing complex operations like subgraph extraction and graph cloning. It also supports event handling for user interactions, allowing for dynamic updates and real-time manipulation of the graph.

  • graphlib:

    graphlib focuses on efficient graph manipulation, providing a simple API for adding and removing nodes and edges, as well as querying graph properties (e.g., neighbors, degree). It also includes algorithms for calculating shortest paths, performing depth-first and breadth-first traversals, and detecting cycles, making it suitable for algorithmic applications.

  • graphology:

    graphology offers a comprehensive set of methods for graph manipulation, including adding/removing nodes and edges, updating attributes, and performing structural modifications. It also supports advanced operations like graph merging, splitting, and filtering, as well as a wide range of algorithms for analysis and manipulation, making it highly versatile for both visualization and data processing.

  • vis-network:

    vis-network provides basic graph manipulation features, such as adding and removing nodes and edges, updating attributes, and handling user interactions. However, it is primarily focused on visualization, so its manipulation capabilities are more limited compared to dedicated graph libraries. It supports real-time updates and interactions, allowing for dynamic changes during visualization.

Visualization Capabilities

  • cytoscape:

    cytoscape excels in graph visualization, offering highly customizable rendering with support for SVG, Canvas, and WebGL. It provides advanced layout algorithms, styling options (e.g., colors, shapes, labels), and support for animations and transitions. The library also allows for interactive features like zooming, panning, and dragging, making it suitable for complex and large-scale visualizations.

  • graphlib:

    graphlib does not provide built-in visualization capabilities, as it is primarily focused on graph data structures and algorithms. However, it can be integrated with other visualization libraries to render graphs based on the data it manages. Its strength lies in its efficient handling of graph data, which can be leveraged by external tools for visualization.

  • graphology:

    graphology provides basic visualization capabilities but is not a dedicated visualization library. It focuses on graph data management and analysis, allowing for integration with other visualization tools and frameworks. The library is designed to be modular, enabling developers to use its visualization features alongside other libraries for more advanced rendering and styling.

  • vis-network:

    vis-network is designed for interactive network visualization, providing an easy-to-use API for rendering graphs with minimal configuration. It supports dynamic layouts, animations, and basic styling, making it suitable for quick and simple visualizations. The library also allows for real-time updates and interactions, such as dragging nodes and zooming, which enhances the user experience.

Performance with Large Graphs

  • cytoscape:

    cytoscape is optimized for performance with large graphs, but its efficiency depends on the complexity of the visualization and the number of elements. The library supports WebGL rendering for better performance with large datasets, and developers can implement techniques like lazy loading, clustering, and simplifying graphs to improve performance further.

  • graphlib:

    graphlib is efficient in handling large graphs, particularly for graph manipulation and algorithmic operations. Its data structures are designed for quick access and modification, making it suitable for applications that require frequent updates and calculations on large graphs. However, it does not provide visualization, so performance considerations are primarily related to data processing.

  • graphology:

    graphology is designed with performance in mind, especially for handling large and complex graphs. Its data structures are optimized for fast manipulation and traversal, and the library supports efficient algorithms for analysis and processing. However, performance may vary depending on the specific operations and algorithms used, so it is important to consider the use case when working with large datasets.

  • vis-network:

    vis-network performs well with moderately sized graphs, but performance may degrade with very large datasets due to the limitations of DOM-based rendering. The library provides options for clustering and simplifying graphs to improve performance, but it is not as optimized for large-scale visualizations as some other libraries. For very large networks, additional performance tuning and optimization may be required.

Ease of Use: Code Examples

  • cytoscape:

    Basic graph manipulation and visualization with cytoscape

    const cy = cytoscape({
      container: document.getElementById('cy'),
      elements: [
        { data: { id: 'a' } },
        { data: { id: 'b' } },
        { data: { id: 'c' } },
        { data: { source: 'a', target: 'b' } },
        { data: { source: 'b', target: 'c' } },
      ],
      style: [
        { selector: 'node', style: { 'background-color': '#666', 'label': 'data(id)' } },
        { selector: 'edge', style: { 'width': 2, 'line-color': '#ccc' } },
      ],
      layout: { name: 'grid' },
    });
    
    // Add a new node and edge
    cy.add([{ data: { id: 'd' } }, { data: { source: 'c', target: 'd' } }]);
    
    // Remove a node
    cy.remove('#a');
    
    // Update node style
    cy.style().selector('#b').style({ 'background-color': 'red' }).update();
    
  • graphlib:

    Graph manipulation with graphlib

    const { Graph } = require('graphlib');
    
    // Create a new directed graph
    const g = new Graph({ directed: true });
    
    // Add nodes
     g.setNode('a');
    g.setNode('b');
    g.setNode('c');
    
    // Add edges
    g.setEdge('a', 'b');
    g.setEdge('b', 'c');
    
    // Get neighbors of a node
    const neighbors = g.neighbors('b');
    console.log('Neighbors of b:', neighbors);
    
    // Calculate shortest path
    const path = g.shortestPath('a', 'c');
    console.log('Shortest path from a to c:', path);
    
    // Remove a node
     g.removeNode('c');
    
    // Remove an edge
     g.removeEdge('a', 'b');
    
  • graphology:

    Graph manipulation and visualization with graphology

    import { Graph } from 'graphology';
    import { Sigma } from 'sigma';
    
    // Create a new graph
    const graph = new Graph();
    
    // Add nodes and edges
    graph.addNode('a', { label: 'Node A' });
    graph.addNode('b', { label: 'Node B' });
    graph.addEdge('a', 'b');
    
    // Visualize the graph with Sigma
    const container = document.getElementById('graph-container');
    const sigma = new Sigma(graph, container);
    
    // Manipulate the graph
    graph.addNode('c', { label: 'Node C' });
    graph.addEdge('b', 'c');
    
    // Update node attributes
    graph.updateNode('a', { label: 'Updated Node A' });
    
    // Remove a node
    graph.dropNode('c');
    
  • vis-network:

    Basic network visualization with vis-network

    const nodes = new vis.DataSet([
      { id: 1, label: 'Node 1' },
      { id: 2, label: 'Node 2' },
      { id: 3, label: 'Node 3' },
    ]);
    
    const edges = new vis.DataSet([
      { from: 1, to: 2 },
      { from: 2, to: 3 },
    ]);
    
    const container = document.getElementById('network');
    const data = { nodes, edges };
    const options = {};
    const network = new vis.Network(container, data, options);
    
    // Add a new node
    nodes.add({ id: 4, label: 'Node 4' });
    
    // Remove a node
    nodes.remove(2);
    
    // Update node label
    nodes.update({ id: 1, label: 'Updated Node 1' });
    
How to Choose: cytoscape vs graphlib vs graphology vs vis-network
  • cytoscape:

    Choose cytoscape if you need a feature-rich library for complex graph visualizations with support for large datasets, advanced layouts, and extensive customization options. It is suitable for applications that require high interactivity and detailed graph analysis.

  • graphlib:

    Choose graphlib if you need a lightweight library focused on graph data structures and algorithms. It is ideal for applications that require efficient graph manipulation, such as adding/removing nodes and edges, calculating shortest paths, or performing graph traversals, without the need for visualization.

  • graphology:

    Choose graphology if you need a versatile library for both graph manipulation and visualization, with a strong emphasis on performance and modularity. It is suitable for applications that require advanced graph algorithms, data analysis, and customizable visualization, while maintaining a small footprint.

  • vis-network:

    Choose vis-network if you need an easy-to-use library for creating interactive network visualizations with minimal setup. It is ideal for applications that require quick and simple graph rendering, with support for basic interactivity, animations, and a user-friendly API.

README for cytoscape

GitHub repo Ask a question with Phind News and tutorials License npm DOI npm installs Automated tests Extensions Cloudflare

Created at the University of Toronto and published in Oxford Bioinformatics (2016, 2023).
Authored by: Max Franz, Christian Lopes, Dylan Fong, Mike Kucera, ..., Gary Bader

Cytoscape.js

Graph theory (network) library for visualisation and analysis : https://js.cytoscape.org

Description

Cytoscape.js is a fully featured graph theory library. Do you need to model and/or visualise relational data, like biological data or social networks? If so, Cytoscape.js is just what you need.

Cytoscape.js contains a graph theory model and an optional renderer to display interactive graphs. This library was designed to make it as easy as possible for programmers and scientists to use graph theory in their apps, whether it's for server-side analysis in a Node.js app or for a rich user interface.

You can get started with Cytoscape.js with one line:

var cy = cytoscape({ elements: myElements, container: myDiv });

Learn more about the features of Cytoscape.js by reading its documentation.

Example

The Tokyo railway stations network can be visualised with Cytoscape:

A live demo and source code are available for the Tokyo railway stations graph. More demos are available in the documentation.

Documentation

You can find the documentation and downloads on the project website.

Roadmap

Future versions of Cytoscape.js are planned in the milestones of the Github issue tracker. You can use the milestones to see what's currently planned for future releases.

Contributing to Cytoscape.js

Would you like to become a Cytoscape.js contributor? You can contribute in technical roles (e.g. features, testing) or non-technical roles (e.g. documentation, outreach), depending on your interests. Get in touch with us by posting a GitHub discussion.

For the mechanics of contributing a pull request, refer to CONTRIBUTING.md.

Feature releases are made monthly, while patch releases are made weekly. This allows for rapid releases of first- and third-party contributions.

Citation

To cite Cytoscape.js in a paper, please cite the Oxford Bioinformatics issue:

Cytoscape.js: a graph theory library for visualisation and analysis

Franz M, Lopes CT, Huck G, Dong Y, Sumer O, Bader GD

Bioinformatics (2016) 32 (2): 309-311 first published online September 28, 2015 doi:10.1093/bioinformatics/btv557 (PDF)

Build dependencies

Install node and npm. Run npm install before using npm run.

Build instructions

Run npm run <target> in the console. The main targets are:

Building:

  • build: do all builds of the library (umd, min, umd, esm)
  • build:min : do the unminified build with bundled dependencies (for simple html pages, good for novices)
  • build:umd : do the umd (cjs/amd/globals) build
  • build:esm : do the esm (ES 2015 modules) build
  • clean : clean the build directory
  • docs : build the docs into documentation
  • release : build all release artifacts
  • watch : automatically build lib for debugging (with sourcemap, no babel, very quick)
    • good for general testing on debug/index.html
    • served on http://localhost:8080 or the first available port thereafter, with livereload on debug/index.html
  • watch:babel : automatically build lib for debugging (with sourcemap, with babel, a bit slower)
    • good for testing performance or for testing out of date browsers
    • served on http://localhost:8080 or the first available port thereafter, with livereload on debug/index.html
  • watch:umd : automatically build prod umd bundle (no sourcemap, with babel)
    • good for testing cytoscape in another project (with a "cytoscape": "file:./path/to/cytoscape" reference in your project's package.json)
    • no http server
  • dist : update the distribution js for npm etc.

Testing:

The default test scripts run directly against the source code. Tests can alternatively be run on a built bundle. The library can be built on node>=6, but the library's bundle can be tested on node>=0.10.

  • test : run all testing & linting
  • test:js : run the mocha tests on the public API of the lib (directly on source files)
    • npm run test:js -- -g "my test name" runs tests on only the matching test cases
  • test:build : run the mocha tests on the public API of the lib (on a built bundle)
    • npm run build should be run beforehand on a recent version of node
    • npm run test:build -- -g "my test name" runs build tests on only the matching test cases
  • test:modules : run unit tests on private, internal API
    • npm run test:modules -- -g "my test name" runs modules tests on only the matching test cases
  • lint : lint the js sources via eslint
  • benchmark : run all benchmarks
  • benchmark:single : run benchmarks only for the suite specified in benchmark/single

Release instructions

Background

  • Ensure that a milestone exists for the release you want to make, with all the issues for that release assigned in the milestone.
  • Bug fixes should be applied to both the master and unstable branches. PRs can go on either branch, with the patch applied to the other branch after merging.
  • When a patch release is made concurrently with a feature release, the patch release should be made first. Wait 5 minutes after the patch release completes before starting the feature release -- otherwise Zenodo doesn't pick up releases properly.

Patch version

  1. Go to Actions > Patch release
  2. Go to the 'Run workflow' dropdown
  3. [Optional] The 'master' branch should be preselected for you
  4. Press the green 'Run workflow' button
  5. Close the milestone for the release

Feature version

  1. Go to Actions > Feature release
  2. Go to the 'Run workflow' dropdown
  3. [Optional] The 'unstable' branch should be preselected for you
  4. Press the green 'Run workflow' button
  5. Close the milestone for the release
  6. Make the release announcement on the blog

Notes on GitHub Actions UI

  • 'Use workflow from' in the GitHub UI selects the branch from which the workflow YML file is selected. Since the workflow files should usually be the same on the master and unstable branches, it shouldn't matter what's selected.
  • 'Branch to run the action on' in the GitHub UI is preselected for you. You don't need to change it.

Tests

Mocha tests are found in the test directory. The tests can be run in the browser or they can be run via Node.js (npm run test:js).