nodes: 0, module; 1, function_definition; 2, function_name:add_nodes_from; 3, parameters; 4, block; 5, identifier:self; 6, identifier:nodes; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, identifier:weights; 12, None; 13, comment:"""
          Add multiple nodes to the Graph.
  
          **The behviour of adding weights is different than in networkx.
  
          Parameters
          ----------
          nodes: iterable container
              A container of nodes (list, dict, set, or any hashable python
              object).
  
          weights: list, tuple (default=None)
              A container of weights (int, float). The weight value at index i
              is associated with the variable at index i.
  
          Examples
          --------
          >>> from pgmpy.base import DAG
          >>> G = DAG()
          >>> G.add_nodes_from(nodes=['A', 'B', 'C'])
          >>> sorted(G.nodes())
          ['A', 'B', 'C']
  
          Adding nodes with weights:
          >>> G.add_nodes_from(nodes=['D', 'E'], weights=[0.3, 0.6])
          >>> G.node['D']
          {'weight': 0.3}
          >>> G.node['E']
          {'weight': 0.6}
          >>> G.node['A']
          {'weight': None}
          """; 14, assignment; 15, identifier:weights; 16, block; 17, else_clause; 18, identifier:nodes; 19, call; 20, if_statement; 21, for_statement; 22, block; 23, identifier:list; 24, argument_list; 25, comparison_operator:len(nodes) != len(weights); 26, block; 27, identifier:index; 28, call; 29, block; 30, for_statement; 31, identifier:nodes; 32, call; 33, call; 34, raise_statement; 35, identifier:range; 36, argument_list; 37, expression_statement; 38, identifier:node; 39, identifier:nodes; 40, block; 41, identifier:len; 42, argument_list; 43, identifier:len; 44, argument_list; 45, call; 46, call; 47, call; 48, expression_statement; 49, identifier:nodes; 50, identifier:weights; 51, identifier:ValueError; 52, argument_list; 53, identifier:len; 54, argument_list; 55, attribute; 56, argument_list; 57, call; 58, concatenated_string; 59, identifier:nodes; 60, identifier:self; 61, identifier:add_node; 62, keyword_argument; 63, keyword_argument; 64, attribute; 65, argument_list; 66, string:"The number of elements in nodes and weights"; 67, string:"should be equal."; 68, identifier:node; 69, subscript; 70, identifier:weight; 71, subscript; 72, identifier:self; 73, identifier:add_node; 74, keyword_argument; 75, identifier:nodes; 76, identifier:index; 77, identifier:weights; 78, identifier:index; 79, identifier:node; 80, identifier:node
code: def add_nodes_from(self, nodes, weights=None):
          """
          Add multiple nodes to the Graph.
  
          **The behviour of adding weights is different than in networkx.
  
          Parameters
          ----------
          nodes: iterable container
              A container of nodes (list, dict, set, or any hashable python
              object).
  
          weights: list, tuple (default=None)
              A container of weights (int, float). The weight value at index i
              is associated with the variable at index i.
  
          Examples
          --------
          >>> from pgmpy.base import DAG
          >>> G = DAG()
          >>> G.add_nodes_from(nodes=['A', 'B', 'C'])
          >>> sorted(G.nodes())
          ['A', 'B', 'C']
  
          Adding nodes with weights:
          >>> G.add_nodes_from(nodes=['D', 'E'], weights=[0.3, 0.6])
          >>> G.node['D']
          {'weight': 0.3}
          >>> G.node['E']
          {'weight': 0.6}
          >>> G.node['A']
          {'weight': None}
          """
          nodes = list(nodes)
  
          if weights:
              if len(nodes) != len(weights):
                  raise ValueError("The number of elements in nodes and weights"
                                   "should be equal.")
              for index in range(len(nodes)):
                  self.add_node(node=nodes[index], weight=weights[index])
          else:
              for node in nodes:
                  self.add_node(node=node)