src/utils.js
// Compute an edge dictionary by its source ID
Compute an edge dictionary by its source ID
Compute an edge dictionary by its source ID
function filterEdgeAndComputeDict(numNodes, edges) {
    const filteredEdges = [];
    const d = new Array(numNodes);
    const h = {};
    for (let i = 0; i < numNodes; i++) {
        d[i] = [];
        h[i] = {};
    }
    let k = 0;
    for (let e of edges) {
        if (e.source !== e.target) {
            let s = Math.min(e.source, e.target),
                t = Math.max(e.source, e.target);
            if (!h[s].hasOwnProperty(t)) {
                d[e.source].push({ nid: e.target, eid: k });
                d[e.target].push({ nid: e.source, eid: k });
                filteredEdges.push({ ...e, eid: k });
                k++;
            }
            h[s][t] = true;
        }
    }
    return { edges: filteredEdges, edgeDict: d };
}
function filterEdgeAndComputeDict ( numNodes , edges ) { const filteredEdges = [ ] ; const d = new Array ( numNodes ) ; const h = { } ; for ( let i = 0 ; i < numNodes ; i ++ ) { d [ i ] = [ ] ; h [ i ] = { } ; } let k = 0 ; for ( let e of edges ) { if ( e . source !== e . target ) { let s = Math . min ( e . source , e . target ) , t = Math . max ( e . source , e . target ) ; if ( ! h [ s ] . hasOwnProperty ( t ) ) { d [ e . source ] . push ( { nid : e . target , eid : k } ) ; d [ e . target ] . push ( { nid : e . source , eid : k } ) ; filteredEdges . push ( { ... e , eid : k } ) ; k ++ ; } h [ s ] [ t ] = true ; } } return { edges : filteredEdges , edgeDict : d } ; }
Compute an edge dictionary by its source ID
Compute an edge dictionary by its source ID
// not self loops // remove dup edges