_finishConnect(event) {
    const pointer = this.body.functions.getPointer(event.center);
    const pointerObj = this.selectionHandler._pointerToPositionObject(pointer);

    // remember the edge id
    let connectFromId = undefined;
    if (this.temporaryIds.edges[0] !== undefined) {
      connectFromId = this.body.edges[this.temporaryIds.edges[0]].fromId;
    }

    // get the overlapping node but NOT the temporary node;
    const overlappingNodeIds =
      this.selectionHandler._getAllNodesOverlappingWith(pointerObj);
    let node = undefined;
    for (let i = overlappingNodeIds.length - 1; i >= 0; i--) {
      // if the node id is NOT a temporary node, accept the node.
      if (this.temporaryIds.nodes.indexOf(overlappingNodeIds[i]) === -1) {
        node = this.body.nodes[overlappingNodeIds[i]];
        break;
      }
    }

    // clean temporary nodes and edges.
    this._cleanupTemporaryNodesAndEdges();

    // perform the connection
    if (node !== undefined) {
      if (node.isCluster === true) {
        alert(
          this.options.locales[this.options.locale]["createEdgeError"] ||
            this.options.locales["en"]["createEdgeError"]
        );
      } else {
        if (
          this.body.nodes[connectFromId] !== undefined &&
          this.body.nodes[node.id] !== undefined
        ) {
          this._performAddEdge(connectFromId, node.id);
        }
      }
    }

    event.controlEdge = { from: connectFromId, to: node ? node.id : undefined };
    this.selectionHandler.generateClickEvent(
      "controlNodeDragEnd",
      event,
      pointer
    );

    // No need to do _generateclickevent('dragEnd') here, the regular dragEnd event fires.
    this.body.emitter.emit("_redraw");
  }
Connect the new edge to the target if one exists, otherwise remove temp line
@param {Event}  event   The event
@private