clusterByEdgeCount(edgeCount, options, refreshData = true) {
    options = this._checkOptions(options);
    const clusters = [];
    const usedNodes = {};
    let edge, edges, relevantEdgeCount;
    // collect the nodes that will be in the cluster
    for (let i = 0; i < this.body.nodeIndices.length; i++) {
      const childNodesObj = {};
      const childEdgesObj = {};
      const nodeId = this.body.nodeIndices[i];
      const node = this.body.nodes[nodeId];

      // if this node is already used in another cluster this session, we do not have to re-evaluate it.
      if (usedNodes[nodeId] === undefined) {
        relevantEdgeCount = 0;
        edges = [];
        for (let j = 0; j < node.edges.length; j++) {
          edge = node.edges[j];
          if (this.clusteredEdges[edge.id] === undefined) {
            if (edge.toId !== edge.fromId) {
              relevantEdgeCount++;
            }
            edges.push(edge);
          }
        }

        // this node qualifies, we collect its neighbours to start the clustering process.
        if (relevantEdgeCount === edgeCount) {
          const checkJoinCondition = function (node) {
            if (
              options.joinCondition === undefined ||
              options.joinCondition === null
            ) {
              return true;
            }

            const clonedOptions = NetworkUtil.cloneOptions(node);
            return options.joinCondition(clonedOptions);
          };

          let gatheringSuccessful = true;
          for (let j = 0; j < edges.length; j++) {
            edge = edges[j];
            const childNodeId = this._getConnectedId(edge, nodeId);
            // add the nodes to the list by the join condition.
            if (checkJoinCondition(node)) {
              childEdgesObj[edge.id] = edge;
              childNodesObj[nodeId] = node;
              childNodesObj[childNodeId] = this.body.nodes[childNodeId];
              usedNodes[nodeId] = true;
            } else {
              // this node does not qualify after all.
              gatheringSuccessful = false;
              break;
            }
          }

          // add to the cluster queue
          if (
            Object.keys(childNodesObj).length > 0 &&
            Object.keys(childEdgesObj).length > 0 &&
            gatheringSuccessful === true
          ) {
            /**
             * Search for cluster data that contains any of the node id's
             * @returns {boolean} true if no joinCondition, otherwise return value of joinCondition
             */
            const findClusterData = function () {
              for (let n = 0; n < clusters.length; ++n) {
                // Search for a cluster containing any of the node id's
                for (const m in childNodesObj) {
                  if (clusters[n].nodes[m] !== undefined) {
                    return clusters[n];
                  }
                }
              }

              return undefined;
            };

            // If any of the found nodes is part of a cluster found in this method,
            // add the current values to that cluster
            const foundCluster = findClusterData();
            if (foundCluster !== undefined) {
              // Add nodes to found cluster if not present
              for (const m in childNodesObj) {
                if (foundCluster.nodes[m] === undefined) {
                  foundCluster.nodes[m] = childNodesObj[m];
                }
              }

              // Add edges to found cluster, if not present
              for (const m in childEdgesObj) {
                if (foundCluster.edges[m] === undefined) {
                  foundCluster.edges[m] = childEdgesObj[m];
                }
              }
            } else {
              // Create a new cluster group
              clusters.push({ nodes: childNodesObj, edges: childEdgesObj });
            }
          }
        }
      }
    }

    for (let i = 0; i < clusters.length; i++) {
      this._cluster(clusters[i].nodes, clusters[i].edges, options, false);
    }

    if (refreshData === true) {
      this.body.emitter.emit("_dataChanged");
    }
  }
Cluster all nodes in the network that have only X edges
@param {number} edgeCount
@param {object} options
@param {boolean} [refreshData]