code: def invert_dependencies(targets):
    
    roots = set()
    inverted_deps = defaultdict(OrderedSet)  # target -> dependent targets
    visited = set()
    path = OrderedSet()
  
    def invert(tgt):
      if tgt in path:
        path_list = list(path)
        cycle_head = path_list.index(tgt)
        cycle = path_list[cycle_head:] + [tgt]
        raise CycleException(cycle)
      path.add(tgt)
      if tgt not in visited:
        visited.add(tgt)
        if tgt.dependencies:
          for dependency in tgt.dependencies:
            inverted_deps[dependency].add(tgt)
            invert(dependency)
        else:
          roots.add(tgt)
  
      path.remove(tgt)
  
    for target in targets:
      invert(target)
  
    return roots, inverted_deps
docs: :API: public
  
    :return: the full graph of dependencies for `targets` and the list of roots.