src/reducers.js
// Determine if all nodes are in a focal group.  If yes return the gid (>0), else return 0
Determine if all nodes are in a focal group.  If yes return the gid (>0), else return 0
Determine if all nodes are in a focal group . If yes return the gid ( > 0 ) else return 0
function findFocalGroups(nodes, isNodeSelected) {
    let r = 0;
    if (nodes.length === 2) {
        const g1 = isNodeSelected[nodes[0]],
            g2 = isNodeSelected[nodes[1]];
        if (g1 > 0 && g2 > 0 && g1 !== g2) {
            return Math.max(g1, g2) + 1;
        }
    } else {
        for (let nid of nodes) {
            if (isNodeSelected[nid]) {
                if (r > 0 && isNodeSelected[nid] !== r) {
                    return 0;
                }
                r = isNodeSelected[nid];
            } else if (r > 0) {
                return 0;
            }
        }
    }
    return r;
}
function findFocalGroups ( nodes , isNodeSelected ) { let r = 0 ; if ( nodes . length === 2 ) { const g1 = isNodeSelected [ nodes [ 0 ] ] , g2 = isNodeSelected [ nodes [ 1 ] ] ; if ( g1 > 0 && g2 > 0 && g1 !== g2 ) { return Math . max ( g1 , g2 ) + 1 ; } } else { for ( let nid of nodes ) { if ( isNodeSelected [ nid ] ) { if ( r > 0 && isNodeSelected [ nid ] !== r ) { return 0 ; } r = isNodeSelected [ nid ] ; } else if ( r > 0 ) { return 0 ; } } } return r ; }
Determine if all nodes are in a focal group.
Determine if all nodes are in a focal group .
// determine if the two nodes between to two different focal group respectively // Other nodes are in the focal group r, but this one is not in r or not focal node // Other nodes are in the focal group, but this one is not