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

Improvment on clustering performance #3862

Merged
merged 3 commits into from
Mar 31, 2018
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
15 changes: 7 additions & 8 deletions lib/network/modules/Clustering.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ class ClusterEngine {

// collect the nodes that will be in the cluster
util.forEach(this.body.nodes, (node, nodeId) => {
let clonedOptions = NetworkUtil.cloneOptions(node);
if (options.joinCondition(clonedOptions) === true) {
if (node.options && options.joinCondition(node.options) === true) {
childNodesObj[nodeId] = node;

// collect the edges that will be in the cluster
Expand Down Expand Up @@ -1222,7 +1221,7 @@ class ClusterEngine {
_updateState() {
let nodeId;
let deletedNodeIds = [];
let deletedEdgeIds = [];
let deletedEdgeIds = {};

/**
* Utility function to iterate over clustering nodes only
Expand Down Expand Up @@ -1273,7 +1272,7 @@ class ClusterEngine {
util.forEach(this.clusteredEdges, (edgeId) => {
let edge = this.body.edges[edgeId];
if (edge === undefined || !edge.endPointsValid()) {
deletedEdgeIds.push(edgeId);
deletedEdgeIds[edgeId] = edgeId;
}
});

Expand All @@ -1282,8 +1281,8 @@ class ClusterEngine {
// So the cluster nodes also need to be scanned for invalid edges
eachClusterNode(function(clusterNode) {
util.forEach(clusterNode.containedEdges, (edge, edgeId) => {
if (!edge.endPointsValid() && deletedEdgeIds.indexOf(edgeId) === -1) {
deletedEdgeIds.push(edgeId);
if (!edge.endPointsValid() && !deletedEdgeIds[edgeId]) {
deletedEdgeIds[edgeId] = edgeId;
}
});
});
Expand All @@ -1309,7 +1308,7 @@ class ClusterEngine {
}

if (!edge.endPointsValid() || !isValid) {
deletedEdgeIds.push(edgeId);
deletedEdgeIds[edgeId] = edgeId;
}
});

Expand All @@ -1325,7 +1324,7 @@ class ClusterEngine {
}

edge.clusteringEdgeReplacingIds = this._filter(edge.clusteringEdgeReplacingIds, function(id) {
return deletedEdgeIds.indexOf(id) === -1;
return !deletedEdgeIds[id];
});
});

Expand Down