Giter Club home page Giter Club logo

ngraph.hde's Introduction

ngraph.hde

This package implements high dimensional graph layout with O(m*(|V| + |E|)) time complexity.

While the layout doesn't necessary look appealing for all possible graphs, this package provides amazing initial configuration for nodes for subsequent refinement by ngraph.forcelayout or d3-force.

Since force based layout convergence speed depends on initial configuration, this library can provide significant boost for large graphs layout.

See the demo here: https://anvaka.github.io/ngraph.hde/

demo

Demo's source code is here

How does it work?

The package follows Graph Drawing by High-Dimensional Embedding paper.

First, the graph is projected into M-dimensional space. In this space adjacent nodes are close to each other. By default M has 50 dimensions.

Then from this M dimensional space we crash graph back into 2D or 3D, or any other D < M where you want to visualize the graph. In this D-dimensional space we can visualize the graph, or use it as starting position for a force based layout.

Usage

npm install ngraph.hde

Then, using your favorite bundler:

let createLayout = require('ngraph.hde');
let createGraph = require('ngraph.graph');

let graph = createGraph(); // your graph.
graph.addLink(1, 2);
graph.addLink(2, 3);
graph.addLink(1, 4);
// set up nodes/vertices and then:

let layout = createLayout(graph);
layout.getNodePosition(1); // returns [-0.7, 0.7]

Current version of the library doesn't support graphs with multiple disconnected components. You'd have to first find the connected components and then use layout on connected parts.

Options

Layout supports a few options:

let layout = createLayout(graph, {
  // Defines number of dimensions in `M` space. If value is larger than number
  // of nodes, then number of nodes is used by default.
  pivotCount: 50,

  // Defines number of components for `getNodePosition()` method. This is number of
  // principal component in the PCA.
  dimensions: 2
});

Support

You can always reach out to me on twitter if you have any questions. If you love this library, please consider sponsoring it https://github.com/sponsors/anvaka .

License

MIT

ngraph.hde's People

Contributors

anvaka avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.