src/components/graph/graph.helper.js
function _validateGraphData(data) {
    if (!data.nodes || !data.nodes.length) {
        utils.throwErr("Graph", ERRORS.INSUFFICIENT_DATA);
    }

    const n = data.links.length;

    for (let i = 0; i < n; i++) {
        const l = data.links[i];

        if (!data.nodes.find(n => n.id === l.source)) {
            utils.throwErr("Graph", `${ERRORS.INVALID_LINKS} - "${l.source}" is not a valid source node id`);
        }

        if (!data.nodes.find(n => n.id === l.target)) {
            utils.throwErr("Graph", `${ERRORS.INVALID_LINKS} - "${l.target}" is not a valid target node id`);
        }

        if (l && l.value !== undefined && typeof l.value !== "number") {
            utils.throwErr(
                "Graph",
                `${ERRORS.INVALID_LINK_VALUE} - found in link with source "${l.source}" and target "${l.target}"`
            );
        }
    }
}
function _validateGraphData(data) {
    if (!data.nodes || !data.nodes.length) {
        utils.throwErr("Graph", ERRORS.INSUFFICIENT_DATA);
    }

    const n = data.links.length;

    for (let i = 0; i < n; i++) {
        const l = data.links[i];

        if (!data.nodes.find(n => n.id === l.source)) {
            utils.throwErr("Graph", `${ERRORS.INVALID_LINKS} - "${l.source}" is not a valid source node id`);
        }

        if (!data.nodes.find(n => n.id === l.target)) {
            utils.throwErr("Graph", `${ERRORS.INVALID_LINKS} - "${l.target}" is not a valid target node id`);
        }

        if (l && l.value !== undefined && typeof l.value !== "number") {
            utils.throwErr(
                "Graph",
                `${ERRORS.INVALID_LINK_VALUE} - found in link with source "${l.source}" and target "${l.target}"`
            );
        }
    }
}
function _validateGraphData ( data ) { if ( ! data . nodes || ! data . nodes . length ) { utils . throwErr ( "Graph" , ERRORS . INSUFFICIENT_DATA ) ; } const n = data . links . length ; for ( let i = 0 ; i < n ; i ++ ) { const l = data . links [ i ] ; if ( ! data . nodes . find ( n => n . id === l . source ) ) { utils . throwErr ( "Graph" , ` ${ ERRORS . INVALID_LINKS } ${ l . source } ` ) ; } if ( ! data . nodes . find ( n => n . id === l . target ) ) { utils . throwErr ( "Graph" , ` ${ ERRORS . INVALID_LINKS } ${ l . target } ` ) ; } if ( l && l . value !== undefined && typeof l . value !== "number" ) { utils . throwErr ( "Graph" , ` ${ ERRORS . INVALID_LINK_VALUE } ${ l . source } ${ l . target } ` ) ; } } }
Some integrity validations on links and nodes structure. If some validation fails the function will
throw an error.
@param  {Object} data - Same as {@link #initializeGraphState|data in initializeGraphState}.
@throws can throw the following error msg:
INSUFFICIENT_DATA - msg if no nodes are provided
INVALID_LINKS - if links point to nonexistent nodes
@returns {undefined}
@memberof Graph/helper
Some integrity validations on links and nodes structure . If some validation fails the function will throw an error .