

def connected_cuthill_mckee_ordering(G, start=None):
    if (start is None):
        (_, start) = find_pseudo_peripheral_node_pair(G)
    (yield start)
    visited = set([start])
    stack = [(start, iter(G[start]))]
    while stack:
        (parent, children) = stack[0]
        if (parent not in visited):
            (yield parent)
        try:
            child = next(children)
            if (child not in visited):
                (yield child)
                visited.add(child)
                nd = sorted(G.degree(n[child]).items(), key=itemgetter(1))
                children = (n for (n, d) in nd)
                stack.append((child, children))
        except StopIteration:
            stack.pop(0)

dataset/ETHPy150Open gkno/gkno_launcher/src/networkx/utils/rcm.py connected_cuthill_mckee_ordering/VarMisuse@138/157 `G`->`n`