def strategy_saturation_largest_first(G, colors):
 distinct_colors = {v: set() for v in G}
 for i in range(len(G)):
  if (i == 0):
   node = max(G, key=G.degree)
   (yield node)
   for v in G[node]:
    distinct_colors[v].add(0)
  else:
   saturation = {v: len(c) for (v, c) in distinct_colors.items() if (v not in colors)}
   node = max(saturation, key=(lambda v: (saturation[v], G.degree(v))))
   (yield node)
   color = colors[node]
   for v in G[node]:
    distinct_colors[v].add(color)

def strategy_saturation_largest_first ( G , colors ) : distinct_colors = { v : set ( ) for v in G } for i in range ( len ( G ) ) : if ( i == 0 ) : node = max ( G , key = G . degree ) ( yield node ) for v in G [ node ] : distinct_colors [ v ] . add ( 0 ) else : saturation = { v : len ( c ) for ( v , c ) in distinct_colors . items ( ) if ( v not in colors ) } node = max ( saturation , key = ( lambda v : ( saturation [ v ] , G . degree ( v ) ) ) ) ( yield node ) color = colors [ node ] for v in G [ node ] : distinct_colors [ v ] . add ( color )
iterates over all the nodes of g in "saturation order" .