code: def inject_dependency(self, dependent, dependency):
      
      if dependent not in self._target_by_address:
        raise ValueError('Cannot inject dependency from {dependent} on {dependency} because the'
                         ' dependent is not in the BuildGraph.'
                         .format(dependent=dependent, dependency=dependency))
  
      # TODO(pl): Unfortunately this is an unhelpful time to error due to a cycle.  Instead, we warn
      # and allow the cycle to appear.  It is the caller's responsibility to call sort_targets on the
      # entire graph to generate a friendlier CycleException that actually prints the cycle.
      # Alternatively, we could call sort_targets after every inject_dependency/inject_target, but
      # that could have nasty performance implications.  Alternative 2 would be to have an internal
      # data structure of the topologically sorted graph which would have acceptable amortized
      # performance for inserting new nodes, and also cycle detection on each insert.
  
      if dependency not in self._target_by_address:
        logger.warning('Injecting dependency from {dependent} on {dependency}, but the dependency'
                       ' is not in the BuildGraph.  This probably indicates a dependency cycle, but'
                       ' it is not an error until sort_targets is called on a subgraph containing'
                       ' the cycle.'
                       .format(dependent=dependent, dependency=dependency))
  
      if dependency in self.dependencies_of(dependent):
        logger.debug('{dependent} already depends on {dependency}'
                     .format(dependent=dependent, dependency=dependency))
      else:
        self._target_dependencies_by_address[dependent].add(dependency)
        self._target_dependees_by_address[dependency].add(dependent)
docs: Injects a dependency from `dependent` onto `dependency`.
  
      It is an error to inject a dependency if the dependent doesn't already exist, but the reverse
      is not an error.
  
      :API: public
  
      :param Address dependent: The (already injected) address of a Target to which `dependency`
        is being added.
      :param Address dependency: The dependency to be injected.