cytoscape-cose-bilkent
Advanced tools
Comparing version 1.6.15 to 2.0.0
{ | ||
"name": "cytoscape-cose-bilkent", | ||
"version": "1.6.15", | ||
"version": "2.0.0", | ||
"description": "The CoSE layout for Cytoscape.js by Bilkent", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -90,2 +90,3 @@ var FDLayout = require('./FDLayout'); | ||
this.calculateNodesToApplyGravitationTo(); | ||
this.calcNoOfChildrenForAllNodes(); | ||
this.graphManager.calcLowestCommonAncestors(); | ||
@@ -207,2 +208,14 @@ this.graphManager.calcInclusionTreeDepths(); | ||
CoSELayout.prototype.calcNoOfChildrenForAllNodes = function () | ||
{ | ||
var node; | ||
var allNodes = this.graphManager.getAllNodes(); | ||
for(i = 0; i < allNodes.length; i++) | ||
{ | ||
node = allNodes[i]; | ||
node.noOfChildren = node.getNoOfChildren(); | ||
} | ||
} | ||
CoSELayout.prototype.createBendpoints = function () { | ||
@@ -209,0 +222,0 @@ var edges = []; |
@@ -18,5 +18,5 @@ var FDLayoutNode = require('./FDLayoutNode'); | ||
this.displacementX = layout.coolingFactor * | ||
(this.springForceX + this.repulsionForceX + this.gravitationForceX); | ||
(this.springForceX + this.repulsionForceX + this.gravitationForceX) / this.noOfChildren; | ||
this.displacementY = layout.coolingFactor * | ||
(this.springForceY + this.repulsionForceY + this.gravitationForceY); | ||
(this.springForceY + this.repulsionForceY + this.gravitationForceY) / this.noOfChildren; | ||
@@ -23,0 +23,0 @@ |
@@ -235,4 +235,12 @@ var Layout = require('./Layout'); | ||
repulsionForceX = overlapAmount[0]; | ||
repulsionForceY = overlapAmount[1]; | ||
repulsionForceX = 2 * overlapAmount[0]; | ||
repulsionForceY = 2 * overlapAmount[1]; | ||
var childrenConstant = nodeA.noOfChildren * nodeB.noOfChildren / (nodeA.noOfChildren + nodeB.noOfChildren); | ||
// Apply forces on the two nodes | ||
nodeA.repulsionForceX -= childrenConstant * repulsionForceX; | ||
nodeA.repulsionForceY -= childrenConstant * repulsionForceY; | ||
nodeB.repulsionForceX += childrenConstant * repulsionForceX; | ||
nodeB.repulsionForceY += childrenConstant * repulsionForceY; | ||
} | ||
@@ -273,3 +281,3 @@ else// no overlap | ||
repulsionForce = this.repulsionConstant / distanceSquared; | ||
repulsionForce = this.repulsionConstant * nodeA.noOfChildren * nodeB.noOfChildren / distanceSquared; | ||
@@ -279,22 +287,9 @@ // Project force onto x and y axes | ||
repulsionForceY = repulsionForce * distanceY / distance; | ||
// Apply forces on the two nodes | ||
nodeA.repulsionForceX -= repulsionForceX; | ||
nodeA.repulsionForceY -= repulsionForceY; | ||
nodeB.repulsionForceX += repulsionForceX; | ||
nodeB.repulsionForceY += repulsionForceY; | ||
} | ||
// Apply forces on the two nodes | ||
// If one node is simple and the other is not, then apply the force only to the simple one | ||
if((nodeA.getChild() != null && nodeB.getChild() == null) || (nodeB.getChild() != null && nodeA.getChild() == null) ){ | ||
if(nodeB.getChild() == null){ | ||
nodeB.repulsionForceX += repulsionForceX; | ||
nodeB.repulsionForceY += repulsionForceY; | ||
} | ||
else{ | ||
nodeA.repulsionForceX -= repulsionForceX; | ||
nodeA.repulsionForceY -= repulsionForceY; | ||
} | ||
} | ||
else{ | ||
nodeA.repulsionForceX -= repulsionForceX; | ||
nodeA.repulsionForceY -= repulsionForceY; | ||
nodeB.repulsionForceX += repulsionForceX; | ||
nodeB.repulsionForceY += repulsionForceY; | ||
} | ||
}; | ||
@@ -317,4 +312,4 @@ | ||
distanceY = node.getCenterY() - ownerCenterY; | ||
absDistanceX = Math.abs(distanceX); | ||
absDistanceY = Math.abs(distanceY); | ||
absDistanceX = Math.abs(distanceX) + node.getWidth() / 2; | ||
absDistanceY = Math.abs(distanceY) + node.getHeight() / 2; | ||
@@ -321,0 +316,0 @@ if (node.getOwner() == this.graphManager.getRoot())// in the root graph |
@@ -223,2 +223,25 @@ var LGraphObject = require('./LGraphObject'); | ||
LNode.prototype.getNoOfChildren = function () | ||
{ | ||
var noOfChildren; | ||
var childNode; | ||
if(this.child == null){ | ||
noOfChildren = 1; | ||
return noOfChildren; | ||
} | ||
else | ||
{ | ||
noOfChildren = 0; | ||
var nodes = this.child.getNodes(); | ||
for (var i = 0; i < nodes.length; i++) | ||
{ | ||
childNode = nodes[i]; | ||
noOfChildren += childNode.getNoOfChildren(); | ||
} | ||
return noOfChildren; | ||
} | ||
}; | ||
LNode.prototype.getEstimatedSize = function () { | ||
@@ -225,0 +248,0 @@ if (this.estimatedSize == Integer.MIN_VALUE) { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
599481
9842