From 683544c51f88233b8fd63cc839584d5d79103c00 Mon Sep 17 00:00:00 2001 From: wimrijnders Date: Thu, 12 Oct 2017 10:29:00 +0200 Subject: [PATCH] Network: Relax clustering condition for adding already clustered nodes 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. --- lib/network/modules/Clustering.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/network/modules/Clustering.js b/lib/network/modules/Clustering.js index 9a0b0144..6d9a1a59 100644 --- a/lib/network/modules/Clustering.js +++ b/lib/network/modules/Clustering.js @@ -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