class_docstr: Implements methods for finding optimal (efficient) backdoor sets.
class_docstr_tok: ["Implements","methods","for","finding","optimal","(","efficient",")","backdoor","sets","."]
docstr: Method to compute the set of all ancestors of a set of nodes.
  A node is always an ancestor of itself.
  
  
  :param nodes: list
      A list of nodes in the graph.
  :returns ancestors: set
      The set of nodes that are ancestors of nodes in nodes.
docstr_tok: ["Method","to","compute","the","set","of","all","ancestors","of","a","set","of","nodes",".","A","node","is","always","an","ancestor","of","itself",".",":","param","nodes",":","list","A","list","of","nodes","in","the","graph",".",":","returns","ancestors",":","set","The","set","of","nodes","that","are","ancestors","of","nodes","in","nodes","."]
code: def ancestors_all(self, nodes):
      """Method to compute the set of all ancestors of a set of nodes.
      A node is always an ancestor of itself.
  
  
      :param nodes: list
          A list of nodes in the graph.
      :returns ancestors: set
          The set of nodes that are ancestors of nodes in nodes.
      """
      ancestors = set()
  
      for node in nodes:
          ancestors_node = nx.ancestors(self.graph, node)
          ancestors = ancestors.union(ancestors_node)
  
      ancestors = ancestors.union(set(nodes))
  
      return ancestors
  
file_path: dowhy/dowhy/causal_identifier/efficient_backdoor.py
imports: from typing import List
  import networkx
  import numpy
label_desc: Use image node_id 2 for calling the EfficientBackdoor obj's underlying member method code with example usage: obj.ancestors_all(nodes) and returns: ancestors