js/motifFinder/broadcastGatherFinder.js
/*
     * Finds a broadcasts/gathers within the group. O(n^2) returns score array
     * where score[i][j] = number of broadcasts between ith and jth node in
     * group inclusive ONLY IF they form a valid broadcast motif
     */
Finds a broadcasts/gathers within the group. O(n^2) returns score array
where score[i][j] = number of broadcasts between ith and jth node in
group inclusive ONLY IF they form a valid broadcast motif
Finds a broadcasts / gathers within the group . O ( n^2 ) returns score array where score [ i ] [ j ] = number of broadcasts between ith and jth node in group inclusive ONLY IF they form a valid broadcast motif
function findAll(group) {
        var score = [];
        for (var i = 0; i < group.length; i++) {
            var count = 0; 
            var inBetween = 0; 
            var seenHosts = {};
            score[i] = [];
            for (var j = i; j < group.length; j++) {
                var curr = group[j];
                var hasValidLink = false;
                var links = context.broadcast ? curr.getChildren() : curr.getParents();
                for (var k = 0; k < links.length; k++) {
                    if (!seenHosts[links[k].getHost()]) {
                        hasValidLink = true;
                        break;
                    }
                }
                var hasBadLink = context.broadcast ? curr.hasParents() : curr.hasChildren();
                var hasGoodLink = context.broadcast ? curr.hasChildren() : curr.hasParents();
                var allowBadLink = context.broadcast && j == i;
                if (inBetween > context.maxInBetween || (hasBadLink && !allowBadLink) || (hasGoodLink && !hasValidLink)) {
                    break;
                }
                if (hasGoodLink) {
                    for (var k = 0; k < links.length; k++) {
                        var childHost = links[k].getHost();
                        if (!seenHosts[childHost]) {
                            count++;
                            seenHosts[childHost] = true;
                        }
                    }
                    inBetween = 1 - curr.getLogEventCount();
                    score[i][j] = count;
                }
                inBetween += curr.getLogEventCount();
            }
        }
        return score;
    }
function findAll ( group ) { var score = [ ] ; for ( var i = 0 ; i < group . length ; i ++ ) { var count = 0 ; var inBetween = 0 ; var seenHosts = { } ; score [ i ] = [ ] ; for ( var j = i ; j < group . length ; j ++ ) { var curr = group [ j ] ; var hasValidLink = false ; var links = context . broadcast ? curr . getChildren ( ) : curr . getParents ( ) ; for ( var k = 0 ; k < links . length ; k ++ ) { if ( ! seenHosts [ links [ k ] . getHost ( ) ] ) { hasValidLink = true ; break ; } } var hasBadLink = context . broadcast ? curr . hasParents ( ) : curr . hasChildren ( ) ; var hasGoodLink = context . broadcast ? curr . hasChildren ( ) : curr . hasParents ( ) ; var allowBadLink = context . broadcast && j == i ; if ( inBetween > context . maxInBetween || ( hasBadLink && ! allowBadLink ) || ( hasGoodLink && ! hasValidLink ) ) { break ; } if ( hasGoodLink ) { for ( var k = 0 ; k < links . length ; k ++ ) { var childHost = links [ k ] . getHost ( ) ; if ( ! seenHosts [ childHost ] ) { count ++ ; seenHosts [ childHost ] = true ; } } inBetween = 1 - curr . getLogEventCount ( ) ; score [ i ] [ j ] = count ; } inBetween += curr . getLogEventCount ( ) ; } } return score ; }
Finds a broadcasts/gathers within the group.
Finds a broadcasts / gathers within the group .
// current broadcast/gather count // Nodes since last valid broadcasting/gathering // node // Check if curr has a valid link (a link to a host that hasn't // been seen yet) // we allow parent links for the first node of a broadcast // (hasGoodLink && !hasValidLink) == has children/parents, but // all of them are to hosts already seen