diff --git a/lib/network/modules/LayoutEngine.js b/lib/network/modules/LayoutEngine.js index 16c90538..8c42ce9a 100644 --- a/lib/network/modules/LayoutEngine.js +++ b/lib/network/modules/LayoutEngine.js @@ -188,6 +188,7 @@ class LayoutEngine { // if less than half of the nodes have a predefined position we continue if (positionDefined < 0.5 * this.body.nodeIndices.length) { + let MAX_LEVELS = 200; let levels = 0; let clusterThreshold = 100; // if there are a lot of nodes, we cluster before we run the algorithm. @@ -204,7 +205,7 @@ class LayoutEngine { this.body.modules.clustering.clusterOutliers(); } let after = this.body.nodeIndices.length; - if (before == after && levels % 3 !== 0) { + if ((before == after && levels % 3 !== 0) || levels > MAX_LEVELS) { this._declusterAll(); console.info("This network could not be positioned by this version of the improved layout algorithm."); return;