Ejemplo n.º 1
0
 def test(node):
     edges = SOA.getedgesintonode(node)
     if len(edges) == 1:
         target = edges[0][1]
         return not matchesemptystring(target) and len(SOA.succ(target) - set([node, target])) <= k
     else:
         return False
Ejemplo n.º 2
0
    def __findextentset__(node, callback):
        '''
        Searches in the direction given by `callback` the node set with an
        "empty" path in from `node`.

        This is useful for both Pred and Succ calculations:

        -   If `callback` returns the ingoing nodes to a given node, then
            this function will return the Pred set.

        -   If `callback` returns the outgoing nodes to a given node, then
            this function will return the Succ set.
        '''
        queue = set(callback(node))
        result = queue.copy()
        trash = set([])
        while len(queue) > 0:
            which = queue.pop()
            trash.add(which)
            if matchesemptystring(which):
                extent = set(callback(which))
                result |= extent
                queue |= extent - trash
        return result