def cuthill_mckee_ordering(G, heuristic=None):
 for c in nx.connected_components(G):
  for n in connected_cuthill_mckee_ordering(G.subgraph(c), heuristic):
   (yield n)

def cuthill_mckee_ordering ( G , heuristic = None ) : for c in nx . connected_components ( G ) : for n in connected_cuthill_mckee_ordering ( G . subgraph ( c ) , heuristic ) : ( yield n )
generate an ordering of the graph nodes to make a sparse matrix .