code: def _partial_precolor(G, chi_ub):
      
  
      # find a random maximal clique and give each node in it a unique color
      v = next(iter(G))
      clique = [v]
      for u in G[v]:
          if all(w in G[u] for w in clique):
              clique.append(u)
  
      partial_coloring = {v: c for c, v in enumerate(clique)}
      chi_lb = len(partial_coloring)  # lower bound for the chromatic number
  
      # now for each uncolored node determine the possible colors
      possible_colors = {v: set(range(chi_ub)) for v in G if v not in partial_coloring}
  
      for v, color in iteritems(partial_coloring):
          for u in G[v]:
              if u in possible_colors:
                  possible_colors[u].discard(color)
  
      # TODO: there is more here that can be done. For instance some nodes now
      # might only have one possible color. Or there might only be one node
      # remaining to color
  
      return partial_coloring, possible_colors, chi_lb
docs: In order to reduce the number of variables in the QUBO, we want to
      color as many nodes as possible without affecting the min vertex
      coloring. Without loss of generality, we can choose a single maximal
      clique and color each node in it uniquely.
  
      Returns
      -------
          partial_coloring : dict
          A dict describing a partial coloring of the nodes of G. Of the form
          {node: color, ...}.
  
          possible_colors : dict
          A dict giving the possible colors for each node in G not already
          colored. Of the form {node: set([color, ...]), ...}.
  
          chi_lb : int
          A lower bound on the chromatic number chi.
  
      Notes
      -----
          partial_coloring.keys() and possible_colors.keys() should be
          disjoint.