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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngraph.hde

v1.0.1

Published

High dimensional embedding of a graph

Downloads

299

Readme

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 by David Harel and Yehuda Koren.

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. The "crash" is a done by PCA. 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, 3);
// set up nodes/vertices and then:

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

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