deleteNode(nodeIndex) {
        const node = this._nodes[nodeIndex];
        if (node.inputs.length > 1) {
            throw new Error('Node deletion with multiple inputs is not supported. ');
        }
        if (node.outputs.length > 1) {
            for (let i = 1; i < node.outputs.length; i++) {
                if (this._allData[node.outputs[i]].to.length > 0) {
                    throw new Error('Node deletion with more than one output connected to other nodes is not supported. ');
                }
            }
        }
        // this node wil not be executed
        node.executeNode = false;
        const inputValueIndex = node.inputs[0];
        const outputValueIndex = node.outputs[0];
        const nodesConsumingOutput = this._allData[outputValueIndex].to;
        // remove this node from the to property of the input Value
        const delIndex = this._allData[inputValueIndex].to.indexOf(nodeIndex);
        // should not happen
        if (delIndex === -1) {
            throw new Error('The Value object doesn\'t have the current Node in it\'s \'to\' property ');
        }
        this._allData[inputValueIndex].to.splice(delIndex, 1);
        // clear node indices consuming this output Value
        this._allData[outputValueIndex]._to = [];
        // if the output of this node is a graph output, adjust the index appropriately
        const index = this._allOutputIndices.indexOf(outputValueIndex);
        if (index !== -1) {
            this._allOutputIndices[index] = inputValueIndex;
        }
        // override the inputs for nodes consuming this node's output with the input to this node
        if (nodesConsumingOutput && nodesConsumingOutput.length > 0) {
            for (const nodeIndex of nodesConsumingOutput) {
                const replaceIndex = this._nodes[nodeIndex].inputs.indexOf(outputValueIndex);
                // should not happen
                if (replaceIndex === -1) {
                    throw new Error('The Node object doesn\'t have the output Value in it\'s \'inputs\' property ');
                }
                this._nodes[nodeIndex].inputs[replaceIndex] = inputValueIndex;
                this._allData[inputValueIndex].to.push(nodeIndex);
            }
        }
    }
/**
     * Delete the specifed node. Assume the node has only one input and the first output connected to other nodes
     * @param nodeIndex The index of node to be deleted
     */
Delete the specifed node. Assume the node has only one input and the first output connected to other nodes
@param nodeIndex The index of node to be deleted
Delete the specifed node . Assume the node has only one input and the first output connected to other nodes @param nodeIndex The index of node to be deleted
deleteNode(nodeIndex) {
        const node = this._nodes[nodeIndex];
        if (node.inputs.length > 1) {
            throw new Error('Node deletion with multiple inputs is not supported. ');
        }
        if (node.outputs.length > 1) {
            for (let i = 1; i < node.outputs.length; i++) {
                if (this._allData[node.outputs[i]].to.length > 0) {
                    throw new Error('Node deletion with more than one output connected to other nodes is not supported. ');
                }
            }
        }
        node.executeNode = false;
        const inputValueIndex = node.inputs[0];
        const outputValueIndex = node.outputs[0];
        const nodesConsumingOutput = this._allData[outputValueIndex].to;
        const delIndex = this._allData[inputValueIndex].to.indexOf(nodeIndex);
        if (delIndex === -1) {
            throw new Error('The Value object doesn\'t have the current Node in it\'s \'to\' property ');
        }
        this._allData[inputValueIndex].to.splice(delIndex, 1);
        this._allData[outputValueIndex]._to = [];
        const index = this._allOutputIndices.indexOf(outputValueIndex);
        if (index !== -1) {
            this._allOutputIndices[index] = inputValueIndex;
        }
        if (nodesConsumingOutput && nodesConsumingOutput.length > 0) {
            for (const nodeIndex of nodesConsumingOutput) {
                const replaceIndex = this._nodes[nodeIndex].inputs.indexOf(outputValueIndex);
                if (replaceIndex === -1) {
                    throw new Error('The Node object doesn\'t have the output Value in it\'s \'inputs\' property ');
                }
                this._nodes[nodeIndex].inputs[replaceIndex] = inputValueIndex;
                this._allData[inputValueIndex].to.push(nodeIndex);
            }
        }
    }
deleteNode ( nodeIndex ) { const node = this . _nodes [ nodeIndex ] ; if ( node . inputs . length > 1 ) { throw new Error ( 'Node deletion with multiple inputs is not supported. ' ) ; } if ( node . outputs . length > 1 ) { for ( let i = 1 ; i < node . outputs . length ; i ++ ) { if ( this . _allData [ node . outputs [ i ] ] . to . length > 0 ) { throw new Error ( 'Node deletion with more than one output connected to other nodes is not supported. ' ) ; } } } node . executeNode = false ; const inputValueIndex = node . inputs [ 0 ] ; const outputValueIndex = node . outputs [ 0 ] ; const nodesConsumingOutput = this . _allData [ outputValueIndex ] . to ; const delIndex = this . _allData [ inputValueIndex ] . to . indexOf ( nodeIndex ) ; if ( delIndex === - 1 ) { throw new Error ( 'The Value object doesn\'t have the current Node in it\'s \'to\' property ' ) ; } this . _allData [ inputValueIndex ] . to . splice ( delIndex , 1 ) ; this . _allData [ outputValueIndex ] . _to = [ ] ; const index = this . _allOutputIndices . indexOf ( outputValueIndex ) ; if ( index !== - 1 ) { this . _allOutputIndices [ index ] = inputValueIndex ; } if ( nodesConsumingOutput && nodesConsumingOutput . length > 0 ) { for ( const nodeIndex of nodesConsumingOutput ) { const replaceIndex = this . _nodes [ nodeIndex ] . inputs . indexOf ( outputValueIndex ) ; if ( replaceIndex === - 1 ) { throw new Error ( 'The Node object doesn\'t have the output Value in it\'s \'inputs\' property ' ) ; } this . _nodes [ nodeIndex ] . inputs [ replaceIndex ] = inputValueIndex ; this . _allData [ inputValueIndex ] . to . push ( nodeIndex ) ; } } }
Delete the specifed node.
Delete the specifed node .
// this node wil not be executed // remove this node from the to property of the input Value // should not happen // clear node indices consuming this output Value // if the output of this node is a graph output, adjust the index appropriately // override the inputs for nodes consuming this node's output with the input to this node // should not happen