|
@ -94,7 +94,9 @@ exports.clusterOutliers = function(options, doNotUpdateCalculationNodes) { |
|
|
this._cluster(clusters[i].nodes, clusters[i].edges, options, true) |
|
|
this._cluster(clusters[i].nodes, clusters[i].edges, options, true) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this._wrapUp(); |
|
|
|
|
|
|
|
|
if (doNotUpdateCalculationNodes !== true) { |
|
|
|
|
|
this._wrapUp(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -114,17 +116,15 @@ exports.clusterByConnection = function(nodeId, options, doNotUpdateCalculationNo |
|
|
if (options.clusterNodeProperties.y === undefined) {options.clusterNodeProperties.y = node.y; options.clusterNodeProperties.allowedToMoveY = !node.yFixed;} |
|
|
if (options.clusterNodeProperties.y === undefined) {options.clusterNodeProperties.y = node.y; options.clusterNodeProperties.allowedToMoveY = !node.yFixed;} |
|
|
|
|
|
|
|
|
var childNodesObj = {}; |
|
|
var childNodesObj = {}; |
|
|
var edge; |
|
|
|
|
|
var childEdgesObj = {} |
|
|
var childEdgesObj = {} |
|
|
var childNodeId; |
|
|
|
|
|
var parentNodeId = node.id; |
|
|
var parentNodeId = node.id; |
|
|
var parentClonedOptions = this._cloneOptions(parentNodeId); |
|
|
var parentClonedOptions = this._cloneOptions(parentNodeId); |
|
|
childNodesObj[parentNodeId] = node; |
|
|
childNodesObj[parentNodeId] = node; |
|
|
|
|
|
|
|
|
// collect the nodes that will be in the cluster
|
|
|
// collect the nodes that will be in the cluster
|
|
|
for (var i = 0; i < node.edges.length; i++) { |
|
|
for (var i = 0; i < node.edges.length; i++) { |
|
|
edge = node.edges[i]; |
|
|
|
|
|
childNodeId = this._getConnectedId(edge, parentNodeId); |
|
|
|
|
|
|
|
|
var edge = node.edges[i]; |
|
|
|
|
|
var childNodeId = this._getConnectedId(edge, parentNodeId); |
|
|
|
|
|
|
|
|
if (childNodeId !== parentNodeId) { |
|
|
if (childNodeId !== parentNodeId) { |
|
|
if (options.joinCondition === undefined) { |
|
|
if (options.joinCondition === undefined) { |
|
@ -148,6 +148,14 @@ exports.clusterByConnection = function(nodeId, options, doNotUpdateCalculationNo |
|
|
this._cluster(childNodesObj, childEdgesObj, options, doNotUpdateCalculationNodes); |
|
|
this._cluster(childNodesObj, childEdgesObj, options, doNotUpdateCalculationNodes); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* This returns a clone of the options or properties of the edge or node to be used for construction of new edges or check functions for new nodes. |
|
|
|
|
|
* @param objId |
|
|
|
|
|
* @param type |
|
|
|
|
|
* @returns {{}} |
|
|
|
|
|
* @private |
|
|
|
|
|
*/ |
|
|
exports._cloneOptions = function(objId, type) { |
|
|
exports._cloneOptions = function(objId, type) { |
|
|
var clonedOptions = {}; |
|
|
var clonedOptions = {}; |
|
|
if (type === undefined || type == 'node') { |
|
|
if (type === undefined || type == 'node') { |
|
@ -161,6 +169,16 @@ exports._cloneOptions = function(objId, type) { |
|
|
return clonedOptions; |
|
|
return clonedOptions; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* This function creates the edges that will be attached to the cluster. |
|
|
|
|
|
* |
|
|
|
|
|
* @param childNodesObj |
|
|
|
|
|
* @param childEdgesObj |
|
|
|
|
|
* @param newEdges |
|
|
|
|
|
* @param options |
|
|
|
|
|
* @private |
|
|
|
|
|
*/ |
|
|
exports._createClusterEdges = function (childNodesObj, childEdgesObj, newEdges, options) { |
|
|
exports._createClusterEdges = function (childNodesObj, childEdgesObj, newEdges, options) { |
|
|
var edge, childNodeId, childNode; |
|
|
var edge, childNodeId, childNode; |
|
|
|
|
|
|
|
@ -209,12 +227,18 @@ exports._createClusterEdges = function (childNodesObj, childEdgesObj, newEdges, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* This function checks the options that can be supplied to the different cluster functions |
|
|
|
|
|
* for certain fields and inserts defaults if needed |
|
|
|
|
|
* @param options |
|
|
|
|
|
* @returns {*} |
|
|
|
|
|
* @private |
|
|
|
|
|
*/ |
|
|
exports._checkOptions = function(options) { |
|
|
exports._checkOptions = function(options) { |
|
|
if (options === undefined) {options = {};} |
|
|
if (options === undefined) {options = {};} |
|
|
if (options.clusterEdgeProperties === undefined) {options.clusterEdgeProperties = {};} |
|
|
if (options.clusterEdgeProperties === undefined) {options.clusterEdgeProperties = {};} |
|
|
if (options.clusterNodeProperties === undefined) {options.clusterNodeProperties = {};} |
|
|
if (options.clusterNodeProperties === undefined) {options.clusterNodeProperties = {};} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return options; |
|
|
return options; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -287,6 +311,7 @@ exports._cluster = function(childNodesObj, childEdgesObj, options, doNotUpdateCa |
|
|
|
|
|
|
|
|
// create the clusterNode
|
|
|
// create the clusterNode
|
|
|
var clusterNode = new Node(clusterNodeProperties, this.images, this.groups, this.constants); |
|
|
var clusterNode = new Node(clusterNodeProperties, this.images, this.groups, this.constants); |
|
|
|
|
|
clusterNode.isCluster = true; |
|
|
clusterNode.containedNodes = childNodesObj; |
|
|
clusterNode.containedNodes = childNodesObj; |
|
|
clusterNode.containedEdges = childEdgesObj; |
|
|
clusterNode.containedEdges = childEdgesObj; |
|
|
|
|
|
|
|
@ -344,6 +369,22 @@ exports._cluster = function(childNodesObj, childEdgesObj, options, doNotUpdateCa |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Check if a node is a cluster. |
|
|
|
|
|
* @param nodeId |
|
|
|
|
|
* @returns {*} |
|
|
|
|
|
*/ |
|
|
|
|
|
exports.isCluster = function(nodeId) { |
|
|
|
|
|
if (this.nodes[nodeId] !== undefined) { |
|
|
|
|
|
return this.nodes[nodeId].isCluster; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
console.log("Node does not exist.") |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* get the position of the cluster node based on what's inside |
|
|
* get the position of the cluster node based on what's inside |
|
|
* @param {object} childNodesObj | object with node objects, id as keys |
|
|
* @param {object} childNodesObj | object with node objects, id as keys |
|
@ -459,6 +500,11 @@ exports.openCluster = function(clusterNodeId, doNotUpdateCalculationNodes) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Recalculate navigation nodes, color edges dirty, update nodes list etc. |
|
|
|
|
|
* @private |
|
|
|
|
|
*/ |
|
|
exports._wrapUp = function() { |
|
|
exports._wrapUp = function() { |
|
|
this._updateNodeIndexList(); |
|
|
this._updateNodeIndexList(); |
|
|
this._updateCalculationNodes(); |
|
|
this._updateCalculationNodes(); |
|
@ -469,6 +515,15 @@ exports._wrapUp = function() { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Connect an edge that was previously contained from cluster A to cluster B if the node that it was originally connected to |
|
|
|
|
|
* is currently residing in cluster B |
|
|
|
|
|
* @param edge |
|
|
|
|
|
* @param nodeId |
|
|
|
|
|
* @param from |
|
|
|
|
|
* @private |
|
|
|
|
|
*/ |
|
|
exports._connectEdge = function(edge, nodeId, from) { |
|
|
exports._connectEdge = function(edge, nodeId, from) { |
|
|
var clusterStack = this._getClusterStack(nodeId); |
|
|
var clusterStack = this._getClusterStack(nodeId); |
|
|
if (from == true) { |
|
|
if (from == true) { |
|
@ -486,6 +541,12 @@ exports._connectEdge = function(edge, nodeId, from) { |
|
|
edge.connect(); |
|
|
edge.connect(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Get the stack clusterId's that a certain node resides in. cluster A -> cluster B -> cluster C -> node |
|
|
|
|
|
* @param nodeId |
|
|
|
|
|
* @returns {Array} |
|
|
|
|
|
* @private |
|
|
|
|
|
*/ |
|
|
exports._getClusterStack = function(nodeId) { |
|
|
exports._getClusterStack = function(nodeId) { |
|
|
var stack = []; |
|
|
var stack = []; |
|
|
var max = 100; |
|
|
var max = 100; |
|
@ -501,6 +562,13 @@ exports._getClusterStack = function(nodeId) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Get the Id the node is connected to |
|
|
|
|
|
* @param edge |
|
|
|
|
|
* @param nodeId |
|
|
|
|
|
* @returns {*} |
|
|
|
|
|
* @private |
|
|
|
|
|
*/ |
|
|
exports._getConnectedId = function(edge, nodeId) { |
|
|
exports._getConnectedId = function(edge, nodeId) { |
|
|
if (edge.toId != nodeId) { |
|
|
if (edge.toId != nodeId) { |
|
|
return edge.toId; |
|
|
return edge.toId; |
|
|