New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

graphology-layout-forceatlas2

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphology-layout-forceatlas2

ForceAtlas 2 layout algorithm for graphology.

  • 0.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
33K
increased by0.88%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status

Graphology ForceAtlas2

JavaScript implementation of the ForceAtlas2 algorithm for graphology.

Reference

Jacomy M, Venturini T, Heymann S, Bastian M (2014) ForceAtlas2, a Continuous Graph Layout Algorithm for Handy Network Visualization Designed for the Gephi Software. PLoS ONE 9(6): e98679. https://doi.org/10.1371/journal.pone.0098679

Installation

npm install graphology-layout-forceatlas2

Usage

Settings

  • adjustSizes ?boolean [false]: should the node's sizes be taken into account?
  • barnesHutOptimize ?boolean [false]: whether to use the Barnes-Hut approximation to compute repulsion in O(n*log(n)) rather than default O(n^2), n being the number of nodes.
  • barnesHutTheta ?number [0.5]: Barnes-Hut approximation theta parameter.
  • edgeWeightInfluence ?number [0]: influence of the edge's weights on the layout.
  • gravity ?number [1]: strength of the layout's gravity.
  • linLogMode ?boolean [false]: whether to use Noack's LinLog model.
  • outboundAttractionDistribution ?boolean [false]
  • scalingRatio ?number [1]
  • slowDown ?number [1]
  • strongGravityMode ?boolean [false]

Synchronous layout

import forceAtlas2 from 'graphology-layout-forceatlas2';

const positions = forceAtlas2(graph, {iterations: 50});

// With settings:
const positions = forceAtlas2(graph, {
  iterations: 50,
  settings: {
    gravity: 10
  }
});

// To directly assign the positions to the nodes:
forceAtlas2.assign(graph);

Arguments

  • graph Graph: target graph.
  • options object: options:
    • iterations number: number of iterations to perform.
    • settings ?object: the layout's settings (see #settings).

Webworker

If you need to run the layout's computation in a web worker, the library comes with a utility to do so:

Example

import FA2Layout from 'graphology-layout-forceatlas2/worker';

const layout = new FA2Layout(graph);

// To start the layout
layout.start({settings: {gravity: 1}});

// To stop the layout
layout.stop();

// To kill the layout and release attached memory
layout.kill();

#.inferSettings

If you don't know how to tune the layout's settings and want to infer them from your graph, you can use the #.inferSettings method:

import forceAtlas2 from 'graphology-layout-forceatlas2';

const saneSettings = forceAtlas2.inferSettings(graph);
const positions = forceAtlas2(graph, {iterations: 50, settings: saneSettings});

Keywords

FAQs

Package last updated on 08 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc