nodes: 0, module; 1, function_definition; 2, function_name:greedy_max_inden_setcover; 3, parameters; 4, block; 5, identifier:candidate_sets_dict; 6, identifier:items; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, while_statement; 14, expression_statement; 15, expression_statement; 16, return_statement; 17, identifier:max_covers; 18, None; 19, comment:"""
      greedy algorithm for maximum independent set cover
  
      Covers items with sets from candidate sets. Could be made faster.
  
      CommandLine:
          python -m utool.util_alg --test-greedy_max_inden_setcover
  
      Example0:
          >>> # ENABLE_DOCTEST
          >>> from utool.util_alg import *  # NOQA
          >>> import utool as ut
          >>> candidate_sets_dict = {'a': [5, 3], 'b': [2, 3, 5],
          ...                        'c': [4, 8], 'd': [7, 6, 2, 1]}
          >>> items = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
          >>> max_covers = None
          >>> tup = greedy_max_inden_setcover(candidate_sets_dict, items, max_covers)
          >>> (uncovered_items, covered_items_list, accepted_keys) = tup
          >>> result = ut.repr4((uncovered_items, sorted(list(accepted_keys))), nl=False)
          >>> print(result)
          ([0, 9], ['a', 'c', 'd'])
  
      Example1:
          >>> # ENABLE_DOCTEST
          >>> from utool.util_alg import *  # NOQA
          >>> import utool as ut
          >>> candidate_sets_dict = {'a': [5, 3], 'b': [2, 3, 5],
          ...                        'c': [4, 8], 'd': [7, 6, 2, 1]}
          >>> items = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
          >>> max_covers = 1
          >>> tup = greedy_max_inden_setcover(candidate_sets_dict, items, max_covers)
          >>> (uncovered_items, covered_items_list, accepted_keys) = tup
          >>> result = ut.repr4((uncovered_items, sorted(list(accepted_keys))), nl=False)
          >>> print(result)
          ([0, 3, 4, 5, 8, 9], ['d'])
      """; 20, assignment; 21, assignment; 22, assignment; 23, assignment; 24, True; 25, comment:# Break if we have enough covers; 26, block; 27, assignment; 28, assignment; 29, identifier:covertup; 30, identifier:uncovered_set; 31, call; 32, identifier:rejected_keys; 33, call; 34, identifier:accepted_keys; 35, call; 36, identifier:covered_items_list; 37, list; 38, if_statement; 39, expression_statement; 40, expression_statement; 41, comment:# Loop over candidates to find the biggested unadded cover set; 42, for_statement; 43, comment:# Add the set to the cover; 44, if_statement; 45, expression_statement; 46, expression_statement; 47, expression_statement; 48, comment:# Add values in this key to the cover; 49, expression_statement; 50, identifier:uncovered_items; 51, call; 52, identifier:covertup; 53, expression_list; 54, identifier:set; 55, argument_list; 56, identifier:set; 57, argument_list; 58, identifier:set; 59, argument_list; 60, boolean_operator; 61, block; 62, assignment; 63, assignment; 64, pattern_list; 65, call; 66, block; 67, comparison_operator:maxkey is None; 68, block; 69, assignment; 70, call; 71, call; 72, call; 73, identifier:list; 74, argument_list; 75, identifier:uncovered_items; 76, identifier:covered_items_list; 77, identifier:accepted_keys; 78, identifier:items; 79, comparison_operator:max_covers is not None; 80, comparison_operator:len(covered_items_list) >= max_covers; 81, break_statement; 82, identifier:maxkey; 83, None; 84, identifier:maxlen; 85, unary_operator; 86, identifier:key; 87, identifier:candidate_items; 88, attribute; 89, argument_list; 90, if_statement; 91, comment:#print('Checking %r' % (key,)); 92, expression_statement; 93, comment:# len(uncovered_set.intersection(candidate_items)) == lenval:; 94, if_statement; 95, identifier:maxkey; 96, None; 97, break_statement; 98, identifier:maxval; 99, subscript; 100, attribute; 101, argument_list; 102, attribute; 103, argument_list; 104, attribute; 105, argument_list; 106, identifier:uncovered_set; 107, identifier:max_covers; 108, None; 109, call; 110, identifier:max_covers; 111, integer:1; 112, identifier:six; 113, identifier:iteritems; 114, identifier:candidate_sets_dict; 115, boolean_operator; 116, block; 117, assignment; 118, call; 119, block; 120, else_clause; 121, identifier:candidate_sets_dict; 122, identifier:maxkey; 123, identifier:accepted_keys; 124, identifier:add; 125, identifier:maxkey; 126, identifier:covered_items_list; 127, identifier:append; 128, call; 129, identifier:uncovered_set; 130, identifier:difference_update; 131, identifier:maxval; 132, identifier:len; 133, argument_list; 134, comparison_operator:key in rejected_keys; 135, comparison_operator:key in accepted_keys; 136, continue_statement; 137, identifier:lenval; 138, call; 139, attribute; 140, argument_list; 141, if_statement; 142, block; 143, identifier:list; 144, argument_list; 145, identifier:covered_items_list; 146, identifier:key; 147, identifier:rejected_keys; 148, identifier:key; 149, identifier:accepted_keys; 150, identifier:len; 151, argument_list; 152, identifier:uncovered_set; 153, identifier:issuperset; 154, identifier:candidate_items; 155, comparison_operator:lenval > maxlen; 156, block; 157, expression_statement; 158, identifier:maxval; 159, identifier:candidate_items; 160, identifier:lenval; 161, identifier:maxlen; 162, expression_statement; 163, expression_statement; 164, call; 165, assignment; 166, assignment; 167, attribute; 168, argument_list; 169, identifier:maxkey; 170, identifier:key; 171, identifier:maxlen; 172, identifier:lenval; 173, identifier:rejected_keys; 174, identifier:add; 175, identifier:key
code: def greedy_max_inden_setcover(candidate_sets_dict, items, max_covers=None):
      """
      greedy algorithm for maximum independent set cover
  
      Covers items with sets from candidate sets. Could be made faster.
  
      CommandLine:
          python -m utool.util_alg --test-greedy_max_inden_setcover
  
      Example0:
          >>> # ENABLE_DOCTEST
          >>> from utool.util_alg import *  # NOQA
          >>> import utool as ut
          >>> candidate_sets_dict = {'a': [5, 3], 'b': [2, 3, 5],
          ...                        'c': [4, 8], 'd': [7, 6, 2, 1]}
          >>> items = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
          >>> max_covers = None
          >>> tup = greedy_max_inden_setcover(candidate_sets_dict, items, max_covers)
          >>> (uncovered_items, covered_items_list, accepted_keys) = tup
          >>> result = ut.repr4((uncovered_items, sorted(list(accepted_keys))), nl=False)
          >>> print(result)
          ([0, 9], ['a', 'c', 'd'])
  
      Example1:
          >>> # ENABLE_DOCTEST
          >>> from utool.util_alg import *  # NOQA
          >>> import utool as ut
          >>> candidate_sets_dict = {'a': [5, 3], 'b': [2, 3, 5],
          ...                        'c': [4, 8], 'd': [7, 6, 2, 1]}
          >>> items = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
          >>> max_covers = 1
          >>> tup = greedy_max_inden_setcover(candidate_sets_dict, items, max_covers)
          >>> (uncovered_items, covered_items_list, accepted_keys) = tup
          >>> result = ut.repr4((uncovered_items, sorted(list(accepted_keys))), nl=False)
          >>> print(result)
          ([0, 3, 4, 5, 8, 9], ['d'])
      """
      uncovered_set = set(items)
      rejected_keys = set()
      accepted_keys = set()
      covered_items_list = []
      while True:
          # Break if we have enough covers
          if max_covers is not None and len(covered_items_list) >= max_covers:
              break
          maxkey = None
          maxlen = -1
          # Loop over candidates to find the biggested unadded cover set
          for key, candidate_items in six.iteritems(candidate_sets_dict):
              if key in rejected_keys or key in accepted_keys:
                  continue
              #print('Checking %r' % (key,))
              lenval = len(candidate_items)
              # len(uncovered_set.intersection(candidate_items)) == lenval:
              if uncovered_set.issuperset(candidate_items):
                  if lenval > maxlen:
                      maxkey = key
                      maxlen = lenval
              else:
                  rejected_keys.add(key)
          # Add the set to the cover
          if maxkey is None:
              break
          maxval = candidate_sets_dict[maxkey]
          accepted_keys.add(maxkey)
          covered_items_list.append(list(maxval))
          # Add values in this key to the cover
          uncovered_set.difference_update(maxval)
      uncovered_items = list(uncovered_set)
      covertup = uncovered_items, covered_items_list, accepted_keys
      return covertup