code: func (t *TargetsTransformer) selectTargetedNodes(g *Graph, addrs []addrs.Targetable) (*dag.Set, error) {
  	targetedNodes := new(dag.Set)
  
  	vertices := g.Vertices()
  
  	for _, v := range vertices {
  		if t.nodeIsTarget(v, addrs) {
  			targetedNodes.Add(v)
  
  			// We inform nodes that ask about the list of targets - helps for nodes
  			// that need to dynamically expand. Note that this only occurs for nodes
  			// that are already directly targeted.
  			if tn, ok := v.(GraphNodeTargetable); ok {
  				tn.SetTargets(addrs)
  			}
  
  			var deps *dag.Set
  			var err error
  			if t.Destroy {
  				deps, err = g.Descendents(v)
  			} else {
  				deps, err = g.Ancestors(v)
  			}
  			if err != nil {
  				return nil, err
  			}
  
  			for _, d := range deps.List() {
  				targetedNodes.Add(d)
  			}
  		}
  	}
  	return t.addDependencies(targetedNodes, g)
  }
docs: // Returns a set of targeted nodes. A targeted node is either addressed
  // directly, address indirectly via its container, or it's a dependency of a
  // targeted node. Destroy mode keeps dependents instead of dependencies.