@staticmethod
    def addRandomFollowOnEdges(childAdjacencyList):
        """
        Adds random follow on edges to the graph, represented as an adjacency list.
        The follow on edges are returned as a set and their augmented edges
        are added to the adjacency list.
        """
        # This function makes the augmented adjacency list
        def makeAugmentedAdjacencyList():
            augmentedAdjacencyList = map(lambda i: childAdjacencyList[i].union(followOnAdjacencyList[i]),
                                         range(len(childAdjacencyList)))

            def addImpliedEdges(node, followOnEdges):
                visited = set()

                def f(node):
                    if visited not in node:
                        visited.add(node)
                        for i in followOnEdges:
                            augmentedAdjacencyList[node].add(i)
                        map(f, childAdjacencyList[node])
                        map(f, followOnAdjacencyList[node])

                map(f, childAdjacencyList[node])

            for node in xrange(len(followOnAdjacencyList)):
                addImpliedEdges(node, followOnAdjacencyList[node])
            return augmentedAdjacencyList

        followOnEdges = set()
        followOnAdjacencyList = map(lambda i: set(), childAdjacencyList)
        # Loop to create the follow on edges (try 1000 times)
        while random.random() > 0.001:
            fNode, tNode = JobTest.getRandomEdge(len(childAdjacencyList))
            # Get the  descendants of fNode not on a path of edges starting with a follow-on
            # edge from fNode
            fDescendants = reduce(lambda i, j: i.union(j), map(lambda c:
                                                               JobTest.reachable(c, childAdjacencyList,
                                                                                 followOnAdjacencyList),
                                                               childAdjacencyList[fNode]), set())
            fDescendants.add(fNode)

            # Make an adjacency list including augmented edges and proposed
            # follow on edge

            # Add the new follow on edge
            followOnAdjacencyList[fNode].add(tNode)

            augmentedAdjacencyList = makeAugmentedAdjacencyList()

            # If the augmented adjacency doesn't contain a cycle then add the follow on edge
            # to the list of follow ons else remove the follow on edge from the follow on
            # adjacency list
            if JobTest.isAcyclic(augmentedAdjacencyList):
                followOnEdges.add((fNode, tNode))
            else:
                followOnAdjacencyList[fNode].remove(tNode)

        # Update adjacency list adding in augmented edges
        childAdjacencyList[:] = makeAugmentedAdjacencyList()[:]

        return followOnEdges
dataset/ETHPy150Open BD2KGenomics/toil/src/toil/test/src/jobTest.py/JobTest.addRandomFollowOnEdges/swapped operands of `not in`