graphology-layout-forceatlas2
Advanced tools
Comparing version 0.0.1 to 0.1.0
16
index.js
@@ -11,17 +11,3 @@ /** | ||
/** | ||
* Default Settings. | ||
*/ | ||
var DEFAULT_SETTINGS = { | ||
linLogMode: false, | ||
outboundAttractionDistribution: false, | ||
adjustSizes: false, | ||
edgeWeightInfluence: 0, | ||
scalingRatio: 1, | ||
strongGravityMode: false, | ||
gravity: 1, | ||
slowDown: 1, | ||
barnesHutOptimize: false, | ||
barnesHutTheta: 0.5 | ||
}; | ||
var DEFAULT_SETTINGS = require('./defaults.js'); | ||
@@ -28,0 +14,0 @@ /** |
@@ -37,2 +37,4 @@ /* eslint no-constant-condition: 0 */ | ||
var SUBDIVISION_ATTEMPTS = 3; | ||
/** | ||
@@ -55,3 +57,3 @@ * Constants. | ||
*/ | ||
module.exports = function(options, NodeMatrix, EdgeMatrix) { | ||
module.exports = function iterate(options, NodeMatrix, EdgeMatrix) { | ||
@@ -106,3 +108,3 @@ // Initializing variables | ||
maxY = -Infinity, | ||
q, q2; | ||
q, q2, subdivisionAttempts; | ||
@@ -117,2 +119,13 @@ // Computing min and max values | ||
// squarify bounds, it's a quadtree | ||
var dx = maxX - minX, dy = maxY - minY; | ||
if (dx > dy) { | ||
minY -= (dx - dy) / 2; | ||
maxY = minY + dx; | ||
} | ||
else { | ||
minX -= (dy - dx) / 2; | ||
maxX = minX + dy; | ||
} | ||
// Build the Barnes Hut root region | ||
@@ -135,2 +148,3 @@ RegionMatrix[0 + REGION_NODE] = -1; | ||
r = 0; | ||
subdivisionAttempts = SUBDIVISION_ATTEMPTS; | ||
@@ -145,3 +159,3 @@ while (true) { | ||
// We just iterate to find a "leave" of the tree | ||
// We just iterate to find a "leaf" of the tree | ||
// that is an empty region or a region with a single node | ||
@@ -196,3 +210,3 @@ // (see next case) | ||
// There are no sub-regions: we are in a "leave" | ||
// There are no sub-regions: we are in a "leaf" | ||
@@ -218,3 +232,3 @@ // Is there a node in this leave? | ||
RegionMatrix[r + REGION_FIRST_CHILD] = l * PPR; | ||
w = RegionMatrix[r + REGION_SIZE] / 2; // new size (half) | ||
w = RegionMatrix[r + REGION_SIZE] / 2; // new size (half) | ||
@@ -342,4 +356,13 @@ // NOTE: we use screen coordinates | ||
// we have to try it again on this quadrant | ||
r = q; | ||
continue; | ||
if (subdivisionAttempts--) { | ||
r = q; | ||
continue; // while | ||
} | ||
else { | ||
// we are out of precision here, and we cannot subdivide anymore | ||
// but we have to break the loop anyway | ||
subdivisionAttempts = SUBDIVISION_ATTEMPTS; | ||
break; // while | ||
} | ||
} | ||
@@ -422,3 +445,3 @@ | ||
if (RegionMatrix[r + REGION_NEXT_SIBLING] < 0) | ||
break; // No next sibling: we have finished the tree | ||
break; // No next sibling: we have finished the tree | ||
r = RegionMatrix[r + REGION_NEXT_SIBLING]; | ||
@@ -481,3 +504,3 @@ continue; | ||
if (RegionMatrix[r + REGION_NEXT_SIBLING] < 0) | ||
break; // No next sibling: we have finished the tree | ||
break; // No next sibling: we have finished the tree | ||
r = RegionMatrix[r + REGION_NEXT_SIBLING]; | ||
@@ -484,0 +507,0 @@ continue; |
{ | ||
"name": "graphology-layout-forceatlas2", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "ForceAtlas 2 layout algorithm for graphology.", | ||
"main": "index.js", | ||
"files": [ | ||
"build", | ||
"helpers.js", | ||
"index.js", | ||
"iterate.js" | ||
"iterate.js", | ||
"supervisor.js", | ||
"worker.js", | ||
"webworker.js" | ||
], | ||
"scripts": { | ||
"bench": "node bench.js", | ||
"build": "webpack --colors --progress && webpack --colors --progress -p", | ||
"lint": "eslint *.js", | ||
"prepublish": "npm test && npm run lint && npm run build", | ||
"test": "mocha test.js" | ||
@@ -35,6 +42,10 @@ }, | ||
"devDependencies": { | ||
"@yomguithereal/eslint-config": "^3.0.0", | ||
"eslint": "^3.5.0", | ||
"graphology": "^0.5.4", | ||
"mocha": "^3.0.2" | ||
"@yomguithereal/eslint-config": "^4.0.0", | ||
"eslint": "^4.7.2", | ||
"graphology": "^0.10.2", | ||
"graphology-generators": "^0.6.1", | ||
"mocha": "^3.0.2", | ||
"seedrandom": "^2.4.3", | ||
"webpack": "^3.6.0", | ||
"worker-loader": "^1.0.0" | ||
}, | ||
@@ -41,0 +52,0 @@ "eslintConfig": { |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
130376
11
2537
8
1