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

Commit

Permalink
Network: Relax clustering condition for adding already clustered node…
Browse files Browse the repository at this point in the history
…s to cluster (#3554)

Previous condition was too strict: if *any* node for the cluster was already clustered, the clustering would abort.

Current fix scans for already clustered nodes and proceeds with what is left.
  • Loading branch information
wimrijnders authored and yotamberk committed Oct 12, 2017
1 parent 4a25c43 commit 683544c
Showing 1 changed file with 13 additions and 8 deletions.
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

0 comments on commit 683544c

Please sign in to comment.