class_docstr: A palette suitable for coloring vertices when plotting a clustering.
  
  This palette tries to make sure that the colors are easily distinguishable.
  This is achieved by using a set of base colors and their lighter and darker
  variants, depending on the number of elements in the palette.
  
  When the desired size of the palette is less than or equal to the number of
  base colors (denoted by M{n}), only the bsae colors will be used. When the
  size of the palette is larger than M{n} but less than M{2*n}, the base colors
  and their lighter variants will be used. Between M{2*n} and M{3*n}, the
  base colors and their lighter and darker variants will be used. Above M{3*n},
  more darker and lighter variants will be generated, but this makes the individual
  colors less and less distinguishable.
class_docstr_tok: ["A","palette","suitable","for","coloring","vertices","when","plotting","a","clustering",".","This","palette","tries","to","make","sure","that","the","colors","are","easily","distinguishable",".","This","is","achieved","by","using","a","set","of","base","colors","and","their","lighter","and","darker","variants",",","depending","on","the","number","of","elements","in","the","palette",".","When","the","desired","size","of","the","palette","is","less","than","or","equal","to","the","number","of","base","colors","(","denoted","by","M","{","n","}",")",",","only","the","bsae","colors","will","be","used",".","When","the","size","of","the","palette","is","larger","than","M","{","n","}","but","less","than","M","{","2","*","n","}",",","the","base","colors","and","their","lighter","variants","will","be","used",".","Between","M","{","2","*","n","}","and","M","{","3","*","n","}",",","the","base","colors","and","their","lighter","and","darker","variants","will","be","used",".","Above","M","{","3","*","n","}",",","more","darker","and","lighter","variants","will","be","generated",",","but","this","makes","the","individual","colors","less","and","less","distinguishable","."]
code: def __init__(self, n):
      base_colors = [
          "red",
          "green",
          "blue",
          "yellow",
          "magenta",
          "cyan",
          "#808080",
      ]
      base_colors = [color_name_to_rgba(name) for name in base_colors]
  
      num_base_colors = len(base_colors)
      colors = base_colors[:]
  
      blocks_to_add = ceil(float(n - num_base_colors) / num_base_colors)
      ratio_increment = 1.0 / (ceil(blocks_to_add / 2.0) + 1)
  
      adding_darker = True
      ratio = ratio_increment
      while len(colors) < n:
          if adding_darker:
              new_block = [
                  darken(color, ratio) for color in base_colors
              ]
          else:
              new_block = [
                  lighten(color, ratio) for color in base_colors
              ]
              ratio += ratio_increment
          colors.extend(new_block)
          adding_darker = not adding_darker
  
      colors = colors[0:n]
      super().__init__(colors)
  
imports: from abc import ABCMeta, abstractmethod
  from math import ceil
label_desc: Use image node_id 1 to create a new ClusterColoringPalette object from inherited base classes: PrecalculatedPalette with example: obj = ClusterColoringPalette(n)