Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cytoscape-fcose

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cytoscape-fcose - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

208

cytoscape-fcose.js

@@ -423,18 +423,20 @@ (function webpackUniversalModuleDefinition(root, factory) {

quality: "default",
// use random node positions at beginning of layout
// Use random node positions at beginning of layout
// if this is set to false, then quality option must be "proof"
randomize: true,
// whether or not to animate the layout
// Whether or not to animate the layout
animate: true,
// duration of animation in ms, if enabled
// Duration of animation in ms, if enabled
animationDuration: 1000,
// easing of animation, if enabled
// Easing of animation, if enabled
animationEasing: undefined,
// fit the viewport to the repositioned nodes
// Fit the viewport to the repositioned nodes
fit: true,
// padding around layout
padding: 10,
// whether to include labels in node dimensions. Valid in "proof" quality
// Padding around layout
padding: 30,
// Whether to include labels in node dimensions. Valid in "proof" quality
nodeDimensionsIncludeLabels: false,
// whether to pack disconnected components - valid only if randomize: true
// Whether or not simple nodes (non-compound nodes) are of uniform dimensions
uniformNodeDimensions: false,
// Whether to pack disconnected components - valid only if randomize: true
packComponents: true,

@@ -444,9 +446,9 @@

// false for random, true for greedy
// False for random, true for greedy
samplingType: true,
// sample size to construct distance matrix
// Sample size to construct distance matrix
sampleSize: 25,
// separation amount between nodes
// Separation amount between nodes
nodeSeparation: 75,
// power iteration tolerance
// Power iteration tolerance
piTol: 0.0000001,

@@ -509,2 +511,6 @@

// if there is no elements, return
if (options.eles.length == 0) return;
// decide component packing is enabled or not
var layUtil = void 0;

@@ -518,4 +524,3 @@ var packingEnabled = false;

if (options.eles.length == 0) return;
// if partial layout, update options.eles
if (options.eles.length != options.cy.elements().length) {

@@ -539,9 +544,22 @@ var prevNodes = eles.nodes();

if (packingEnabled) {
// if packing is not enabled, perform layout on the whole graph
if (!packingEnabled) {
if (options.randomize) {
// Apply spectral layout
spectralResult.push(spectralLayout(options));
xCoords = spectralResult[0]["xCoords"];
yCoords = spectralResult[0]["yCoords"];
}
// Apply cose layout as postprocessing
if (options.quality == "default" || options.quality == "proof") {
coseResult.push(coseLayout(options, spectralResult[0]));
}
} else {
// packing is enabled
var topMostNodes = aux.getTopMostNodes(options.eles.nodes());
components = aux.connectComponents(cy, options.eles, topMostNodes);
}
if (options.randomize) {
if (packingEnabled) {
//send each component to spectral layout
if (options.randomize) {
components.forEach(function (component) {

@@ -551,74 +569,44 @@ options.eles = component;

});
} else {
// Apply spectral layout
spectralResult.push(spectralLayout(options));
if (spectralResult[0]) {
xCoords = spectralResult[0]["xCoords"];
yCoords = spectralResult[0]["yCoords"];
}
}
}
if (options.quality == "default" || options.quality == "proof" || spectralResult.includes(false)) {
if (packingEnabled) {
if (options.quality == "draft" && spectralResult.includes(false)) {
spectralResult.forEach(function (value, index) {
if (!value) {
options.eles = components[index];
var tempResult = coseLayout(options, spectralResult[index]);
var nodeIndexes = new Map();
var _xCoords = [];
var _yCoords = [];
var count = 0;
Object.keys(tempResult).forEach(function (item) {
nodeIndexes.set(item, count++);
_xCoords.push(tempResult[item].getCenterX());
_yCoords.push(tempResult[item].getCenterY());
if (options.quality == "default" || options.quality == "proof") {
var toBeTiledNodes = cy.collection();
if (options.tile) {
// behave nodes to be tiled as one component
var nodeIndexes = new Map();
var _xCoords = [];
var _yCoords = [];
var count = 0;
var tempSpectralResult = { nodeIndexes: nodeIndexes, xCoords: _xCoords, yCoords: _yCoords };
var indexesToBeDeleted = [];
components.forEach(function (component, index) {
if (component.edges().length == 0) {
component.nodes().forEach(function (node, i) {
toBeTiledNodes.merge(component.nodes()[i]);
if (!node.isParent()) {
tempSpectralResult.nodeIndexes.set(component.nodes()[i].id(), count++);
tempSpectralResult.xCoords.push(component.nodes()[0].position().x);
tempSpectralResult.yCoords.push(component.nodes()[0].position().y);
}
});
spectralResult[index] = { nodeIndexes: nodeIndexes, xCoords: _xCoords, yCoords: _yCoords };
indexesToBeDeleted.push(index);
}
});
} else {
var toBeTiledNodes = cy.collection();
if (options.tile) {
var nodeIndexes = new Map();
var _xCoords2 = [];
var _yCoords2 = [];
var count = 0;
var tempSpectralResult = { nodeIndexes: nodeIndexes, xCoords: _xCoords2, yCoords: _yCoords2 };
var indexesToBeDeleted = [];
components.forEach(function (component, index) {
if (component.edges().length == 0) {
component.nodes().forEach(function (node, i) {
toBeTiledNodes.merge(component.nodes()[i]);
if (!node.isParent()) {
tempSpectralResult.nodeIndexes.set(component.nodes()[i].id(), count++);
tempSpectralResult.xCoords.push(component.nodes()[0].position().x);
tempSpectralResult.yCoords.push(component.nodes()[0].position().y);
}
});
indexesToBeDeleted.push(index);
}
});
if (toBeTiledNodes.length > 1) {
components.push(toBeTiledNodes);
for (var i = indexesToBeDeleted.length - 1; i >= 0; i--) {
components.splice(indexesToBeDeleted[i], 1);
spectralResult.splice(indexesToBeDeleted[i], 1);
};
spectralResult.push(tempSpectralResult);
}
if (toBeTiledNodes.length > 1) {
components.push(toBeTiledNodes);
spectralResult.push(tempSpectralResult);
for (var i = indexesToBeDeleted.length - 1; i >= 0; i--) {
components.splice(indexesToBeDeleted[i], 1);
spectralResult.splice(indexesToBeDeleted[i], 1);
};
}
components.forEach(function (component, index) {
options.eles = component;
coseResult.push(coseLayout(options, spectralResult[index]));
});
}
} else {
// Apply cose layout as postprocessing
coseResult.push(coseLayout(options, spectralResult[0]));
components.forEach(function (component, index) {
// send each component to cose layout
options.eles = component;
coseResult.push(coseLayout(options, spectralResult[index]));
});
}
}
if (packingEnabled) {
// packing
var subgraphs = [];

@@ -638,3 +626,3 @@ components.forEach(function (component, index) {

nodeIndex = nodeIndexes.get(node.id());
subgraph.nodes.push({ x: spectralResult[index].xCoords[nodeIndex] - node.bb().w / 2, y: spectralResult[index].yCoords[nodeIndex] - node.bb().h / 2, width: node.bb().w, height: node.bb().h });
subgraph.nodes.push({ x: spectralResult[index].xCoords[nodeIndex] - node.boundingbox().w / 2, y: spectralResult[index].yCoords[nodeIndex] - node.boundingbox().h / 2, width: node.boundingbox().w, height: node.boundingbox().h });
} else {

@@ -648,2 +636,31 @@ var parentInfo = aux.calcBoundingBox(node, spectralResult[index].xCoords, spectralResult[index].yCoords, nodeIndexes);

});
component.edges().forEach(function (node) {
var source = node.source();
var target = node.target();
if (options.quality == "draft") {
var sourceNodeIndex = nodeIndexes.get(source.id());
var targetNodeIndex = nodeIndexes.get(target.id());
var sourceCenter = [];
var targetCenter = [];
if (source.isParent()) {
var parentInfo = aux.calcBoundingBox(source, spectralResult[index].xCoords, spectralResult[index].yCoords, nodeIndexes);
sourceCenter.push(parentInfo.topLeftX + parentInfo.width / 2);
sourceCenter.push(parentInfo.topLeftY + parentInfo.height / 2);
} else {
sourceCenter.push(spectralResult[index].xCoords[sourceNodeIndex]);
sourceCenter.push(spectralResult[index].yCoords[sourceNodeIndex]);
}
if (target.isParent()) {
var _parentInfo = aux.calcBoundingBox(target, spectralResult[index].xCoords, spectralResult[index].yCoords, nodeIndexes);
targetCenter.push(_parentInfo.topLeftX + _parentInfo.width / 2);
targetCenter.push(_parentInfo.topLeftY + _parentInfo.height / 2);
} else {
targetCenter.push(spectralResult[index].xCoords[targetNodeIndex]);
targetCenter.push(spectralResult[index].yCoords[targetNodeIndex]);
}
subgraph.edges.push({ startX: sourceCenter[0], startY: sourceCenter[1], endX: targetCenter[0], endY: targetCenter[1] });
} else {
subgraph.edges.push({ startX: coseResult[index][source.id()].getCenterX(), startY: coseResult[index][source.id()].getCenterY(), endX: coseResult[index][target.id()].getCenterX(), endY: coseResult[index][target.id()].getCenterY() });
}
});
subgraphs.push(subgraph);

@@ -675,3 +692,3 @@ });

var getPositions = function getPositions(ele, i) {
if (options.quality == "default" || options.quality == "proof" || options.quality == "proof" && !packingEnabled && spectralResult.includes(false)) {
if (options.quality == "default" || options.quality == "proof") {
if (typeof ele === "number") {

@@ -697,4 +714,5 @@ ele = i;

_pos = { x: result.xCoords[index], y: result.yCoords[index] };
};
}
});
if (_pos == undefined) _pos = { x: ele.position("x"), y: ele.position("y") };
return {

@@ -778,3 +796,3 @@ x: _pos.x,

if (options.randomize && spectralResult) {
if (options.randomize) {
nodeIndexes = spectralResult["nodeIndexes"];

@@ -800,3 +818,3 @@ xCoords = spectralResult["xCoords"];

if (theChild.outerWidth() != null && theChild.outerHeight() != null) {
if (options.randomize && spectralResult) {
if (options.randomize) {
if (!theChild.isParent()) {

@@ -889,2 +907,3 @@ theNode = parent.add(new CoSENode(layout.graphManager, new PointD(xCoords[nodeIndexes.get(theChild.id())] - dimensions.w / 2, yCoords[nodeIndexes.get(theChild.id())] - dimensions.h / 2), new DimensionD(parseFloat(dimensions.w), parseFloat(dimensions.h))));

CoSEConstants.DEFAULT_INCREMENTAL = FDLayoutConstants.DEFAULT_INCREMENTAL = LayoutConstants.DEFAULT_INCREMENTAL = true;
LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES = options.uniformNodeDimensions;

@@ -1342,3 +1361,16 @@ var coseLayout = new CoSELayout();

} else {
spectralResult = false;
var iterator = nodeIndexes.keys();
var firstNode = cy.getElementById(iterator.next().value);
var firstNodePos = firstNode.position();
var firstNodeWidth = firstNode.outerWidth();
xCoords.push(firstNodePos.x);
yCoords.push(firstNodePos.y);
if (nodeSize == 2) {
var secondNode = cy.getElementById(iterator.next().value);
var secondNodeWidth = secondNode.outerWidth();
xCoords.push(firstNodePos.x + firstNodeWidth / 2 + secondNodeWidth / 2 + options.idealEdgeLength);
yCoords.push(firstNodePos.y);
}
spectralResult = { nodeIndexes: nodeIndexes, xCoords: xCoords, yCoords: yCoords };
return spectralResult;

@@ -1345,0 +1377,0 @@ }

{
"name": "cytoscape-fcose",
"version": "1.1.0",
"version": "1.2.0",
"description": "The fCoSE layout for Cytoscape.js by Bilkent with fast compound node placement",

@@ -5,0 +5,0 @@ "main": "cytoscape-fcose.js",

@@ -82,18 +82,20 @@ cytoscape-fcose

quality: "default",
// use random node positions at beginning of layout
// Use random node positions at beginning of layout
// if this is set to false, then quality option must be "proof"
randomize: true,
// whether or not to animate the layout
// Whether or not to animate the layout
animate: true,
// duration of animation in ms, if enabled
// Duration of animation in ms, if enabled
animationDuration: 1000,
// easing of animation, if enabled
// Easing of animation, if enabled
animationEasing: undefined,
// fit the viewport to the repositioned nodes
// Fit the viewport to the repositioned nodes
fit: true,
// padding around layout
padding: 10,
// whether to include labels in node dimensions. Valid in "proof" quality
// Padding around layout
padding: 30,
// Whether to include labels in node dimensions. Valid in "proof" quality
nodeDimensionsIncludeLabels: false,
// whether to pack disconnected components - valid only if randomize: true
// Whether or not simple nodes (non-compound nodes) are of uniform dimensions
uniformNodeDimensions: false,
// Whether to pack disconnected components - valid only if randomize: true
packComponents: true,

@@ -103,9 +105,9 @@

// false for random, true for greedy sampling
// False for random, true for greedy sampling
samplingType: true,
// sample size to construct distance matrix
// Sample size to construct distance matrix
sampleSize: 25,
// separation amount between nodes
// Separation amount between nodes
nodeSeparation: 75,
// power iteration tolerance
// Power iteration tolerance
piTol: 0.0000001,

@@ -123,4 +125,2 @@

nestingFactor: 0.1,
// Gravity force (constant)
gravity: 0.25,
// Maximum number of iterations to perform

@@ -134,2 +134,4 @@ numIter: 2500,

tilingPaddingHorizontal: 10,
// Gravity force (constant)
gravity: 0.25,
// Gravity range (constant) for compounds

@@ -136,0 +138,0 @@ gravityRangeCompound: 1.5,

@@ -26,3 +26,3 @@ /**

if(options.randomize && spectralResult){
if(options.randomize){
nodeIndexes = spectralResult["nodeIndexes"];

@@ -49,3 +49,3 @@ xCoords = spectralResult["xCoords"];

&& theChild.outerHeight() != null) {
if(options.randomize && spectralResult){
if(options.randomize){
if(!theChild.isParent()){

@@ -163,2 +163,3 @@ theNode = parent.add(new CoSENode(layout.graphManager,

CoSEConstants.DEFAULT_INCREMENTAL = FDLayoutConstants.DEFAULT_INCREMENTAL = LayoutConstants.DEFAULT_INCREMENTAL = true;
LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES = options.uniformNodeDimensions;

@@ -165,0 +166,0 @@ let coseLayout = new CoSELayout();

@@ -17,18 +17,20 @@ /**

quality: "default",
// use random node positions at beginning of layout
// Use random node positions at beginning of layout
// if this is set to false, then quality option must be "proof"
randomize: true,
// whether or not to animate the layout
// Whether or not to animate the layout
animate: true,
// duration of animation in ms, if enabled
// Duration of animation in ms, if enabled
animationDuration: 1000,
// easing of animation, if enabled
// Easing of animation, if enabled
animationEasing: undefined,
// fit the viewport to the repositioned nodes
// Fit the viewport to the repositioned nodes
fit: true,
// padding around layout
padding: 10,
// whether to include labels in node dimensions. Valid in "proof" quality
// Padding around layout
padding: 30,
// Whether to include labels in node dimensions. Valid in "proof" quality
nodeDimensionsIncludeLabels: false,
// whether to pack disconnected components - valid only if randomize: true
// Whether or not simple nodes (non-compound nodes) are of uniform dimensions
uniformNodeDimensions: false,
// Whether to pack disconnected components - valid only if randomize: true
packComponents: true,

@@ -38,9 +40,9 @@

// false for random, true for greedy
// False for random, true for greedy
samplingType: true,
// sample size to construct distance matrix
// Sample size to construct distance matrix
sampleSize: 25,
// separation amount between nodes
// Separation amount between nodes
nodeSeparation: 75,
// power iteration tolerance
// Power iteration tolerance
piTol: 0.0000001,

@@ -98,3 +100,8 @@

let components;
// if there is no elements, return
if(options.eles.length == 0)
return;
// decide component packing is enabled or not
let layUtil;

@@ -109,5 +116,3 @@ let packingEnabled = false;

if(options.eles.length == 0)
return;
// if partial layout, update options.eles
if(options.eles.length != options.cy.elements().length){

@@ -130,10 +135,23 @@ let prevNodes = eles.nodes();

}
if(packingEnabled){
// if packing is not enabled, perform layout on the whole graph
if(!packingEnabled){
if(options.randomize){
// Apply spectral layout
spectralResult.push(spectralLayout(options));
xCoords = spectralResult[0]["xCoords"];
yCoords = spectralResult[0]["yCoords"];
}
// Apply cose layout as postprocessing
if(options.quality == "default" || options.quality == "proof"){
coseResult.push(coseLayout(options, spectralResult[0]));
}
}
else{ // packing is enabled
let topMostNodes = aux.getTopMostNodes(options.eles.nodes());
components = aux.connectComponents(cy, options.eles, topMostNodes);
}
components = aux.connectComponents(cy, options.eles, topMostNodes);
if(options.randomize){
if(packingEnabled){
//send each component to spectral layout
if(options.randomize){
components.forEach(function(component){

@@ -144,35 +162,6 @@ options.eles = component;

}
else{
// Apply spectral layout
spectralResult.push(spectralLayout(options));
if(spectralResult[0]){
xCoords = spectralResult[0]["xCoords"];
yCoords = spectralResult[0]["yCoords"];
}
}
}
if(options.quality == "default" || options.quality == "proof" || spectralResult.includes(false)){
if(packingEnabled){
if(options.quality == "draft" && spectralResult.includes(false)){
spectralResult.forEach(function(value, index){
if(!value){
options.eles = components[index];
let tempResult = coseLayout(options, spectralResult[index]);
let nodeIndexes = new Map();
let xCoords = [];
let yCoords = [];
let count = 0;
Object.keys(tempResult).forEach(function (item) {
nodeIndexes.set(item, count++);
xCoords.push(tempResult[item].getCenterX());
yCoords.push(tempResult[item].getCenterY());
});
spectralResult[index] = {nodeIndexes: nodeIndexes, xCoords: xCoords, yCoords: yCoords};
}
});
}
else{
if(options.quality == "default" || options.quality == "proof"){
let toBeTiledNodes = cy.collection();
if(options.tile){
if(options.tile){ // behave nodes to be tiled as one component
let nodeIndexes = new Map();

@@ -199,2 +188,3 @@ let xCoords = [];

components.push(toBeTiledNodes);
spectralResult.push(tempSpectralResult);
for(let i = indexesToBeDeleted.length-1; i >= 0; i--){

@@ -204,18 +194,11 @@ components.splice(indexesToBeDeleted[i], 1);

};
spectralResult.push(tempSpectralResult);
}
}
components.forEach(function(component, index){
components.forEach(function(component, index){ // send each component to cose layout
options.eles = component;
coseResult.push(coseLayout(options, spectralResult[index]));
});
}
});
}
else{
// Apply cose layout as postprocessing
coseResult.push(coseLayout(options, spectralResult[0]));
}
}
if(packingEnabled){
// packing
let subgraphs = [];

@@ -235,3 +218,3 @@ components.forEach(function(component, index){

nodeIndex = nodeIndexes.get(node.id());
subgraph.nodes.push({x: spectralResult[index].xCoords[nodeIndex] - node.bb().w/2, y: spectralResult[index].yCoords[nodeIndex] - node.bb().h/2, width: node.bb().w, height: node.bb().h});
subgraph.nodes.push({x: spectralResult[index].xCoords[nodeIndex] - node.boundingbox().w/2, y: spectralResult[index].yCoords[nodeIndex] - node.boundingbox().h/2, width: node.boundingbox().w, height: node.boundingbox().h});
}

@@ -247,2 +230,34 @@ else{

});
component.edges().forEach(function (node) {
let source = node.source();
let target = node.target();
if(options.quality == "draft"){
let sourceNodeIndex = nodeIndexes.get(source.id());
let targetNodeIndex = nodeIndexes.get(target.id());
let sourceCenter = [];
let targetCenter = [];
if(source.isParent()){
let parentInfo = aux.calcBoundingBox(source, spectralResult[index].xCoords, spectralResult[index].yCoords, nodeIndexes);
sourceCenter.push(parentInfo.topLeftX + parentInfo.width / 2);
sourceCenter.push(parentInfo.topLeftY + parentInfo.height / 2);
}
else{
sourceCenter.push(spectralResult[index].xCoords[sourceNodeIndex]);
sourceCenter.push(spectralResult[index].yCoords[sourceNodeIndex]);
}
if(target.isParent()){
let parentInfo = aux.calcBoundingBox(target, spectralResult[index].xCoords, spectralResult[index].yCoords, nodeIndexes);
targetCenter.push(parentInfo.topLeftX + parentInfo.width / 2);
targetCenter.push(parentInfo.topLeftY + parentInfo.height / 2);
}
else{
targetCenter.push(spectralResult[index].xCoords[targetNodeIndex]);
targetCenter.push(spectralResult[index].yCoords[targetNodeIndex]);
}
subgraph.edges.push({startX: sourceCenter[0], startY: sourceCenter[1], endX: targetCenter[0], endY: targetCenter[1]});
}
else{
subgraph.edges.push({startX: coseResult[index][source.id()].getCenterX(), startY: coseResult[index][source.id()].getCenterY(), endX: coseResult[index][target.id()].getCenterX(), endY: coseResult[index][target.id()].getCenterY()});
}
});
subgraphs.push(subgraph);

@@ -266,3 +281,4 @@ });

});
}
}
}

@@ -272,3 +288,3 @@

let getPositions = function(ele, i ){
if(options.quality == "default" || options.quality == "proof" || (options.quality == "proof" && !packingEnabled && spectralResult.includes(false))) {
if(options.quality == "default" || options.quality == "proof") {
if(typeof ele === "number") {

@@ -295,4 +311,6 @@ ele = i;

pos = {x: result.xCoords[index], y: result.yCoords[index]};
};
}
});
if(pos == undefined)
pos = {x: ele.position("x"), y: ele.position("y")};
return {

@@ -306,3 +324,3 @@ x: pos.x,

// quality = "draft" and randomize = false are contradictive so in that case positions don't change
if((options.quality == "default" || options.quality == "proof") || options.randomize) {
if(options.quality == "default" || options.quality == "proof" || options.randomize) {
// transfer calculated positions to nodes (positions of only simple nodes are evaluated, compounds are positioned automatically)

@@ -309,0 +327,0 @@ options.eles = eles;

@@ -400,3 +400,16 @@ /**

else {
spectralResult = false;
let iterator = nodeIndexes.keys();
let firstNode = cy.getElementById(iterator.next().value);
let firstNodePos = firstNode.position();
let firstNodeWidth = firstNode.outerWidth();
xCoords.push(firstNodePos.x);
yCoords.push(firstNodePos.y);
if(nodeSize == 2){
let secondNode = cy.getElementById(iterator.next().value);
let secondNodeWidth = secondNode.outerWidth();
xCoords.push(firstNodePos.x + firstNodeWidth / 2 + secondNodeWidth / 2 + options.idealEdgeLength);
yCoords.push(firstNodePos.y);
}
spectralResult = { nodeIndexes: nodeIndexes, xCoords: xCoords, yCoords: yCoords };
return spectralResult;

@@ -403,0 +416,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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