def yield_subgraphs(nodes):
    """Yield node lists representing subgraphs of given nodes.

    Subgraphs are not yielded twice, so if a node
    in the given list was already referenced in another
    previously yielded subgraph, it is ignored (we actually
    remove it from the set of nodes to check).

    Parameters
    ==========

    nodes (iterable w/
    graphman.callablenode.CallableNode instances)
        nodes whose subgraphs will be yielded, one by one,
        in no particular order, since we use this iterable
        to obtain a set with which we work;

        by subgraph we mean a list containing all the nodes
        forming that particular subgraph.
    """
    ### obtain a set from the given nodes, considering them
    ### as nodes to check
    nodes_to_check = set(nodes)

    ### execute this loop while there's still nodes to
    ### be checked

    while nodes_to_check:

        ## pop and reference a node from the set
        node = nodes_to_check.pop()

        ## list all the nodes from that node's subgraph,
        ## including that node itself
        subgraph = list(yield_subgraph_nodes(node))

        ## yield such list
        yield subgraph

        ## now remove from our set all the nodes from
        ## the subgraph which may be present there
        ##
        ## this way we prevent the same subgraph to be
        ## yielded twice, as no node in this subgraph
        ## will be checked again, since we are removing
        ## them from the set of nodes to be checked
        nodes_to_check.difference_update(subgraph)
Yield node lists representing subgraphs of given nodes.

    Subgraphs are not yielded twice, so if a node
    in the given list was already referenced in another
    previously yielded subgraph, it is ignored (we actually
    remove it from the set of nodes to check).

    Parameters
    ==========

    nodes (iterable w/
    graphman.callablenode.CallableNode instances)
        nodes whose subgraphs will be yielded, one by one,
        in no particular order, since we use this iterable
        to obtain a set with which we work;

        by subgraph we mean a list containing all the nodes
        forming that particular subgraph.
    
nodezator/graphman/utils.py