ribolands/utils.py
def tarjans(complexes, products):
    """ Tarjans algorithm to find strongly connected components. 
    Dirctly from the peppercornenumerator project.
    """
    stack, SCCs = [], []
    def strongconnect(at, index):
        stack.append(at)
        at.index = index
        at.llink = index
        index += 1
        for to in products[at]:
            if to.index is None:
                # Product hasn't been traversed; recurse
                strongconnect(to, index)
            if to in stack:
                # Product is in the current neighborhood
                at.llink = min(at.llink, to.llink)

        if at.index == at.llink:
            # Back to the start, get the SCC.
            scc = [] 
            while True:
                nc = stack.pop()
                nc.llink == at.index
                scc.append(nc)
                if nc == at:
                    break
            SCCs.append(scc)

    for cplx in complexes: 
        cplx.index = None

    for i, cplx in enumerate(complexes):
        if cplx.index is None:
            strongconnect(cplx, i)
    return SCCs
 Tarjans algorithm to find strongly connected components. 
    Dirctly from the peppercornenumerator project.
    
Tarjans algorithm to find strongly connected components.
Dirctly from the peppercornenumerator project.
Tarjans algorithm to find strongly connected components . Dirctly from the peppercornenumerator project .
def tarjans(complexes, products):
    stack, SCCs = [], []
    def strongconnect(at, index):
        stack.append(at)
        at.index = index
        at.llink = index
        index += 1
        for to in products[at]:
            if to.index is None:
                strongconnect(to, index)
            if to in stack:
                at.llink = min(at.llink, to.llink)
        if at.index == at.llink:
            scc = [] 
            while True:
                nc = stack.pop()
                nc.llink == at.index
                scc.append(nc)
                if nc == at:
                    break
            SCCs.append(scc)
    for cplx in complexes: 
        cplx.index = None
    for i, cplx in enumerate(complexes):
        if cplx.index is None:
            strongconnect(cplx, i)
    return SCCs
def tarjans ( complexes , products ) : stack , SCCs = [ ] , [ ] def strongconnect ( at , index ) : stack . append ( at ) at . index = index at . llink = index index += 1 for to in products [ at ] : if to . index is None : strongconnect ( to , index ) if to in stack : at . llink = min ( at . llink , to . llink ) if at . index == at . llink : scc = [ ] while True : nc = stack . pop ( ) nc . llink == at . index scc . append ( nc ) if nc == at : break SCCs . append ( scc ) for cplx in complexes : cplx . index = None for i , cplx in enumerate ( complexes ) : if cplx . index is None : strongconnect ( cplx , i ) return SCCs
Tarjans algorithm to find strongly connected components.
Tarjans algorithm to find strongly connected components .
""" Tarjans algorithm to find strongly connected components. 
    Dirctly from the peppercornenumerator project.
    """ # Product hasn't been traversed; recurse # Product is in the current neighborhood # Back to the start, get the SCC.
complexes
products