def strategy_connected_sequential(G, colors, traversal='bfs'):
 if (traversal == 'bfs'):
  traverse = nx.bfs_edges
 elif (traversal == 'dfs'):
  traverse = nx.dfs_edges
 else:
  raise nx.NetworkXError("Please specify one of the strings 'bfs' or 'dfs' for connected sequential ordering")
 for component in nx.connected_component_subgraphs(G):
  source = arbitrary_element(component)
  (yield source)
  for (_, end) in traverse(component, source):
   (yield end)

def strategy_connected_sequential ( G , colors , traversal = 'bfs' ) : if ( traversal == 'bfs' ) : traverse = nx . bfs_edges elif ( traversal == 'dfs' ) : traverse = nx . dfs_edges else : raise nx . NetworkXError ( "Please specify one of the strings 'bfs' or 'dfs' for connected sequential ordering" ) for component in nx . connected_component_subgraphs ( G ) : source = arbitrary_element ( component ) ( yield source ) for ( _ , end ) in traverse ( component , source ) : ( yield end )
returns an iterable over nodes in g in the order given by a breadth-first or depth-first traversal .