diff --git a/LICENSE b/LICENSE index 8b23445..0c3c5fc 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 +Copyright (c) 2019 - present, iVis@Bilkent. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/cose-base.js b/cose-base.js index 43051c2..29986d7 100644 --- a/cose-base.js +++ b/cose-base.js @@ -104,6 +104,7 @@ CoSEConstants.DEFAULT_COMPONENT_SEPERATION = 60; CoSEConstants.TILE = true; CoSEConstants.TILING_PADDING_VERTICAL = 10; CoSEConstants.TILING_PADDING_HORIZONTAL = 10; +CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL = false; // make this true when cose is used incrementally as a part of other non-incremental layout module.exports = CoSEConstants; @@ -395,6 +396,18 @@ CoSELayout.prototype.classicLayout = function () { this.positionNodesRandomly(); } + } else { + if (CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL) { + // Reduce the trees in incremental mode if only this constant is set to true + this.reduceTrees(); + // Update nodes that gravity will be applied + this.graphManager.resetAllNodesToApplyGravitation(); + var allNodes = new Set(this.getAllNodes()); + var intersection = this.nodesWithGravity.filter(function (x) { + return allNodes.has(x); + }); + this.graphManager.setAllNodesToApplyGravitation(intersection); + } } this.initSpringEmbedder(); diff --git a/package-lock.json b/package-lock.json index 2755ebe..f05af6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5630,7 +5630,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -5651,12 +5652,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -5671,17 +5674,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -5798,7 +5804,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -5810,6 +5817,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -5824,6 +5832,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -5831,12 +5840,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -5855,6 +5866,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -5935,7 +5947,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -5947,6 +5960,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -6032,7 +6046,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -6068,6 +6083,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -6087,6 +6103,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -6130,12 +6147,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, diff --git a/src/CoSEConstants.js b/src/CoSEConstants.js index 45bb2c2..639e59c 100644 --- a/src/CoSEConstants.js +++ b/src/CoSEConstants.js @@ -14,5 +14,6 @@ CoSEConstants.DEFAULT_COMPONENT_SEPERATION = 60; CoSEConstants.TILE = true; CoSEConstants.TILING_PADDING_VERTICAL = 10; CoSEConstants.TILING_PADDING_HORIZONTAL = 10; +CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL = false; // make this true when cose is used incrementally as a part of other non-incremental layout module.exports = CoSEConstants; diff --git a/src/CoSELayout.js b/src/CoSELayout.js index f146cae..3882781 100644 --- a/src/CoSELayout.js +++ b/src/CoSELayout.js @@ -130,6 +130,17 @@ CoSELayout.prototype.classicLayout = function () { this.positionNodesRandomly(); } } + else { + if(CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL){ + // Reduce the trees in incremental mode if only this constant is set to true + this.reduceTrees(); + // Update nodes that gravity will be applied + this.graphManager.resetAllNodesToApplyGravitation(); + var allNodes = new Set(this.getAllNodes()); + var intersection = this.nodesWithGravity.filter(x => allNodes.has(x)); + this.graphManager.setAllNodesToApplyGravitation(intersection); + } + } this.initSpringEmbedder(); this.runSpringEmbedder();