cytoscape vs d3-graphviz vs vis-network
图形可视化库
cytoscaped3-graphvizvis-network类似的npm包:

图形可视化库

图形可视化库是用于创建和操作图形(节点和边)的工具,广泛应用于网络分析、数据可视化和图形算法研究。它们提供了丰富的API和交互功能,帮助开发者以直观的方式展示复杂的关系数据。cytoscape 是一个功能强大的图形可视化库,支持大规模图形的渲染和分析,适合需要复杂布局和交互的应用。d3-graphviz 是基于 D3.js 的图形可视化工具,利用 Graphviz 的布局算法,适合需要精确控制图形布局的应用。vis-network 是一个易于使用的网络可视化库,提供丰富的交互功能,适合快速构建动态网络图。

npm下载趋势

3 年

GitHub Stars 排名

统计详情

npm包名称
下载量
Stars
大小
Issues
发布时间
License
cytoscape011,0145.68 MB1712 天前MIT
d3-graphviz01,7982.92 MB232 年前BSD-3-Clause
vis-network03,57282.7 MB34516 天前(Apache-2.0 OR MIT)

功能对比: cytoscape vs d3-graphviz vs vis-network

布局算法

  • cytoscape:

    cytoscape 提供多种布局算法,包括力导向布局、层次布局和网格布局,适合不同类型的图形。它支持自定义布局,允许开发者根据需求调整节点和边的位置。

  • d3-graphviz:

    d3-graphviz 利用 Graphviz 的布局算法,如层次布局(dot)、力导向布局(neato)和圆形布局(circo),提供高质量的图形布局。它特别适合有向图和层次结构的可视化。

  • vis-network:

    vis-network 提供力导向布局和层次布局,支持动态调整节点和边的位置。它允许用户通过拖拽节点进行交互,布局算法可以根据用户操作实时更新。

交互功能

  • cytoscape:

    cytoscape 支持丰富的交互功能,包括节点和边的选择、拖拽、缩放和平移。它还支持事件监听,允许开发者实现自定义的交互逻辑。

  • d3-graphviz:

    d3-graphviz 主要依赖 D3.js 的交互功能,支持缩放和平移,但对节点和边的交互支持较为基础。开发者可以利用 D3.js 的能力实现更复杂的交互。

  • vis-network:

    vis-network 提供丰富的交互功能,包括节点和边的选择、拖拽、缩放和平移。它还支持工具提示、弹出窗口和事件监听,适合构建高度交互的网络图。

数据处理

  • cytoscape:

    cytoscape 支持多种数据格式,包括 JSON、GraphML 和 CSV,方便导入和导出图形数据。它还提供 API 进行动态数据更新,适合实时应用。

  • d3-graphviz:

    d3-graphviz 主要使用 DOT 语言描述图形,适合从文本格式导入图形数据。它与 D3.js 集成,允许动态更新图形。

  • vis-network:

    vis-network 支持 JSON 格式的数据导入,允许动态添加、删除和更新节点和边。它提供简单的 API,方便处理实时数据。

可扩展性

  • cytoscape:

    cytoscape 具有高度可扩展性,支持插件和扩展,允许开发者添加自定义功能和布局。它的架构设计使其适合大型项目和复杂应用。

  • d3-graphviz:

    d3-graphviz 基于 D3.js,具有良好的可扩展性,允许开发者利用 D3.js 的强大功能进行二次开发。它适合需要高度定制化的图形可视化。

  • vis-network:

    vis-network 支持自定义样式和事件,允许开发者扩展其功能。它的设计简单,适合快速集成和扩展。

代码示例

  • cytoscape:

    cytoscape 示例:

    const cy = cytoscape({
      container: document.getElementById('cy'),
      elements: [
        { data: { id: 'a' } },
        { data: { id: 'b' } },
        { data: { id: 'ab', source: 'a', target: 'b' } }
      ],
      layout: { name: 'grid' },
      style: [
        { selector: 'node', style: { 'background-color': '#666', 'label': 'data(id)' } },
        { selector: 'edge', style: { 'width': 3, 'line-color': '#ccc' } }
      ]
    });
    
  • d3-graphviz:

    d3-graphviz 示例:

    const graphviz = d3.select('#graph').graphviz();
    graphviz.renderDot('digraph { a -> b; b -> c; c -> a; }');
    
  • vis-network:

    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: 1, to: 3 }
    ]);
    const container = document.getElementById('network');
    const data = { nodes, edges };
    const options = {};
    const network = new vis.Network(container, data, options);
    

如何选择: cytoscape vs d3-graphviz vs vis-network

  • cytoscape:

    选择 cytoscape 如果你需要一个功能全面的图形可视化库,支持复杂的布局和交互,适合处理大规模图形数据。它提供了丰富的API,适合需要高度定制化的应用。

  • d3-graphviz:

    选择 d3-graphviz 如果你需要利用 Graphviz 的布局算法进行图形可视化,特别是对于层次结构和有向图。它适合需要精确控制节点和边布局的应用,尤其是在学术和工程领域。

  • vis-network:

    选择 vis-network 如果你需要一个易于使用且功能丰富的网络可视化库,支持动态数据和交互。它适合快速构建网络图,特别是在需要用户交互和动画的应用中。

cytoscape的README

GitHub repo 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, cjs, 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).