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 - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

17

helpers.js

@@ -156,9 +156,12 @@ /**

exports.assignLayoutChanges = function(graph, NodeMatrix) {
var nodes = graph.nodes();
var i = 0;
for (var i = 0, j = 0, l = NodeMatrix.length; i < l; i += PPN) {
graph.setNodeAttribute(nodes[j], 'x', NodeMatrix[i]);
graph.setNodeAttribute(nodes[j], 'y', NodeMatrix[i + 1]);
j++;
}
graph.updateEachNodeAttributes(function(node, attr) {
attr.x = NodeMatrix[i];
attr.y = NodeMatrix[i + 1];
i += PPN;
return attr;
}, {attributes: ['x', 'y']});
};

@@ -175,3 +178,3 @@

var nodes = graph.nodes(),
positions = Object.create(null);
positions = {};

@@ -178,0 +181,0 @@ for (var i = 0, j = 0, l = NodeMatrix.length; i < l; i += PPN) {

@@ -30,2 +30,3 @@ import Graph from 'graphology-types';

inferSettings(order: number): ForceAtlas2Settings;
inferSettings(graph: Graph): ForceAtlas2Settings;

@@ -32,0 +33,0 @@ }

@@ -65,7 +65,7 @@ /**

*
* @param {Graph} graph - Target graph.
* @param {Graph|number} graph - Target graph or graph order.
* @return {object}
*/
function inferSettings(graph) {
var order = graph.order;
var order = typeof graph === 'number' ? graph : graph.order;

@@ -72,0 +72,0 @@ return {

{
"name": "graphology-layout-forceatlas2",
"version": "0.6.0",
"version": "0.6.1",
"description": "ForceAtlas 2 layout algorithm for graphology.",

@@ -20,2 +20,3 @@ "main": "index.js",

"prepublish": "npm run clean && npm test && npm run lint && npm run template",
"prepublishOnly": "npm run prepublish",
"template": "node ./scripts/template-webworker.js > webworker.js",

@@ -45,8 +46,8 @@ "test": "mocha test.js"

"@yomguithereal/eslint-config": "^4.0.0",
"eslint": "^7.13.0",
"graphology": "0.19.2",
"eslint": "^7.28.0",
"graphology": "0.19.3",
"graphology-generators": "^0.11.0",
"graphology-layout": "^0.4.0",
"graphology-types": "^0.19.0",
"mocha": "^8.2.1",
"graphology-types": "^0.19.2",
"mocha": "^8.4.0",
"rimraf": "^3.0.2",

@@ -65,4 +66,4 @@ "seedrandom": "^3.0.5"

"dependencies": {
"graphology-utils": "^1.8.0"
"graphology-utils": "^2.1.0"
}
}

@@ -100,4 +100,7 @@ [![Build Status](https://travis-ci.org/graphology/graphology-layout-forceatlas2.svg)](https://travis-ci.org/graphology/graphology-layout-forceatlas2)

const saneSettings = forceAtlas2.inferSettings(graph);
const positions = forceAtlas2(graph, {iterations: 50, settings: saneSettings});
const sensibleSettings = forceAtlas2.inferSettings(graph);
const positions = forceAtlas2(graph, {iterations: 50, settings: sensibleSettings});
// Alternatively using the graph's order instead of a graph instance
const sensibleSettings = forceAtlas2.inferSettings(500);
```

@@ -47,19 +47,22 @@ /**

var alreadyRespawning = false;
var respawnFrame = undefined;
var self = this;
this.handleAddition = function() {
if (alreadyRespawning)
return;
this.handleGraphUpdate = function() {
if (self.worker)
self.worker.terminate();
alreadyRespawning = true;
if (respawnFrame)
clearTimeout(respawnFrame);
self.spawnWorker();
setImmediate(function() {
alreadyRespawning = false;
});
respawnFrame = setTimeout(function() {
respawnFrame = undefined;
self.spawnWorker();
}, 0);
};
graph.on('nodeAdded', this.handleAddition);
graph.on('edgeAdded', this.handleAddition);
graph.on('nodeAdded', this.handleGraphUpdate);
graph.on('edgeAdded', this.handleGraphUpdate);
graph.on('nodeDropped', this.handleGraphUpdate);
graph.on('edgeDropped', this.handleGraphUpdate);

@@ -181,4 +184,6 @@ // Spawning worker

// Unbinding listeners
this.graph.removeListener('nodeAdded', this.handleAddition);
this.graph.removeListener('edgeAdded', this.handleAddition);
this.graph.removeListener('nodeAdded', this.handleGraphUpdate);
this.graph.removeListener('edgeAdded', this.handleGraphUpdate);
this.graph.removeListener('nodeDropped', this.handleGraphUpdate);
this.graph.removeListener('edgeDropped', this.handleGraphUpdate);
};

@@ -185,0 +190,0 @@

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