@not_implemented_for('undirected')
def strongly_connected_components_recursive(G):
    def visit(v, cnt):
        root[v] = cnt
        visited[v] = cnt
        cnt += 1
        stack.append(v)
        for w in G[v]:
            if w not in visited:
                for c in visit(w, cnt):
                    yield c
            if w not in component:
                root[v] = min(root[v], root[w])
        if root[v] == visited[v]:
            component[v] = root[v]
            tmpc = {v}  # hold nodes in this component
            while stack[-1] != v:
                w = stack.pop()
                component[w] = root[v]
                tmpc.add(w)
            stack.remove(v)
            yield tmpc

    visited = {}
    component = {}
    root = {}
    cnt = 0
    stack = []
    for source in G:
        if source not in visited:
            for c in visit(source, cnt):
                yield c
Generate nodes in strongly connected components of graph.
dataset/ETHPy150Open networkx/networkx/networkx/algorithms/components/strongly_connected.py/strongly_connected_components_recursive