class_docstr: Base class for structure models, which are an extension of ``networkx.DiGraph``.
  
  A ``StructureModel`` stores nodes and edges with optional data, or attributes.
  
  Edges have one required attribute, "origin", which describes how the edge was created.
  Origin can be one of either unknown, learned, or expert.
  
  StructureModel hold directed edges, describing a cause -> effect relationship.
  Cycles are permitted within a ``StructureModel``.
  
  Nodes can be arbitrary (hashable) Python objects with optional key/value attributes.
  By convention None is not used as a node.
  
  Edges are represented as links between nodes with optional key/value attributes.
class_docstr_tok: ["Base","class","for","structure","models",",","which","are","an","extension","of","``","networkx.DiGraph","``",".","A","``","StructureModel","``","stores","nodes","and","edges","with","optional","data",",","or","attributes",".","Edges","have","one","required","attribute",",","``","origin","''",",","which","describes","how","the","edge","was","created",".","Origin","can","be","one","of","either","unknown",",","learned",",","or","expert",".","StructureModel","hold","directed","edges",",","describing","a","cause","-",">","effect","relationship",".","Cycles","are","permitted","within","a","``","StructureModel","``",".","Nodes","can","be","arbitrary","(","hashable",")","Python","objects","with","optional","key\/value","attributes",".","By","convention","None","is","not","used","as","a","node",".","Edges","are","represented","as","links","between","nodes","with","optional","key\/value","attributes","."]
docstr: Get Markov blanket of specified target nodes
  
  Args:
      nodes: Target node name or list/set of target nodes
  
  Returns:
      Markov blanket of the target node(s)
  
  Raises:
      NodeNotFound: if one of the target nodes is not found in the graph.
docstr_tok: ["Get","Markov","blanket","of","specified","target","nodes","Args",":","nodes",":","Target","node","name","or","list\/set","of","target","nodes","Returns",":","Markov","blanket","of","the","target","node","(","s",")","Raises",":","NodeNotFound",":","if","one","of","the","target","nodes","is","not","found","in","the","graph","."]
code: def get_markov_blanket(
      self, nodes: Union[Any, List[Any], Set[Any]]
  ) -> "StructureModel":
      """
      Get Markov blanket of specified target nodes
  
      Args:
          nodes: Target node name or list/set of target nodes
  
      Returns:
          Markov blanket of the target node(s)
  
      Raises:
          NodeNotFound: if one of the target nodes is not found in the graph.
      """
      if not isinstance(nodes, (list, set)):
          nodes = [nodes]
  
      blanket_nodes = set()
  
      for node in set(nodes):  # Ensure target nodes are unique
          if node not in set(self.nodes):
              raise NodeNotFound(f"Node {node} not found in the graph.")
  
          blanket_nodes.add(node)
          blanket_nodes.update(self.predecessors(node))
  
          for child in self.successors(node):
              blanket_nodes.add(child)
              blanket_nodes.update(self.predecessors(child))
  
      blanket = StructureModel()
      blanket.add_nodes_from(blanket_nodes)
      blanket.add_weighted_edges_from(
          [
              (u, v, w)
              for u, v, w in self.edges(data="weight")
              if u in blanket_nodes and v in blanket_nodes
          ]
      )
      return blanket
  
file_path: causalnex/causalnex/structure/structuremodel.py
imports: from typing import Any, Hashable, List, Set, Tuple, Union
  import networkx
  import numpy
  from networkx.exception import NodeNotFound
label_desc: Use image node_id 12 for calling the StructureModel obj's underlying member method code with example usage: obj.get_markov_blanket(nodes) and returns: blanket