Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Network: Relax condition for adding already clustered nodes to cluster #3554

Merged
merged 1 commit into from
Oct 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions lib/network/modules/Clustering.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,21 +524,26 @@ class ClusterEngine {
* @private
*/
_cluster(childNodesObj, childEdgesObj, options, refreshData = true) {
// kill condition: no nodes don't bother
if (Object.keys(childNodesObj).length == 0) {return;}

// allow clusters of 1 if options allow
if (Object.keys(childNodesObj).length == 1 && options.clusterNodeProperties.allowSingleNodeCluster != true) {return;}

// check if this cluster call is not trying to cluster anything that is in another cluster.
// Remove nodes which are already clustered
var tmpNodesToRemove = []
for (let nodeId in childNodesObj) {
if (childNodesObj.hasOwnProperty(nodeId)) {
if (this.clusteredNodes[nodeId] !== undefined) {
return;
tmpNodesToRemove.push(nodeId);
}
}
}

for (var n = 0; n < tmpNodesToRemove.length; ++n) {
delete childNodesObj[tmpNodesToRemove[n]];
}

// kill condition: no nodes don't bother
if (Object.keys(childNodesObj).length == 0) {return;}

// allow clusters of 1 if options allow
if (Object.keys(childNodesObj).length == 1 && options.clusterNodeProperties.allowSingleNodeCluster != true) {return;}

let clusterNodeProperties = util.deepExtend({},options.clusterNodeProperties);

// construct the clusterNodeProperties
Expand Down