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

isom-layout

v1.0.1

Published

ISOM graph layout (Self-Organizing Maps)

Downloads

6

Readme

Self-Organizing maps layout - SOM npm version

Thumb

After Self-Organizing Graphs: A Neural Network Perspective of Graph Layout by Bernd Meyer.

Usage

npm install `isom-layout`;
import som from 'isom-layout';

const graph = {
  nodes: [
    { id: 0, data: ...},
    { id: 1, data: ...},
    ...
  ],
  edges: [
    { source: 0, target: 1, data: ...},
    ...
  ]
};

// if your nodes have no initial positions
som.randomize(graph, bounds);

// modifies coord in-place
som(graph, {
  // other options, see below
  bounds: bounds,  // [xmin, ymin, xmax, ymax],
  onUpdate: () => {
    // do your rendering here
  },
  onEnd: () => {
    // converged
  }
});

Options

To understand the options you need to know a bit about how algorithm works. Basically, it

  1. picks random points in the graph space
  2. finds the closest node to this random location
  3. using kind of BFS it continiously pulls the nodes and its neighbours in the direction of the random point.
  4. while sweeps are repeated, cooling effect takes place, reducing the pulling force
  5. also the radius gets gradually reduced so that during the last stage smaller areas of graph are getting changed

som(graph, options)

  • maxIterations Maximum algorithm sweeps. default 2000
  • adaption Initial force value. default 0.8
  • radius Maximum graph-theoretical distance of the nodes involved in one sweep. default 3
  • coolingFactor Cooling speed, see the cooling equation, default 2
  • iterationsPerRadiusStep How fast the radius is decreased. default 70
  • iterationsPerUpdate How many iterations to perform between the "ticks", default 10 - for demo purposes. For the default params it means that the algorithm will re-render every 10ms, 200 renders in total
  • updateDelay Delay between the update groups. default 0
  • onUpdate Update callback. Put your rendering here
  • onEnd Complete callback
  • bounds Coordinate space boundaries. [xmin,ymin,xmax,ymax]. If not provided, algorithm will attempt to calculate them from the current nodes positions. So either bounds or initial coordinates have to be provided
  • dontRandomize Don't re-shuffle the node positions. default false

Notes

My impression - useless. The only thing it shows more or less is the nodes with highest degrees. Maybe it can be good on simple chains. You can endlessly tweak the parametres, but it doesn't give you a nice comprehensible layout. So this a mere exercise in understanding the parameters and nature of the algorithms like this one.

Also funny observation: it works as if an impatient person was untangling a threadball by randomly pulling the outstanding knots and strings.

License

MIT