code: def add_nodes_from(self, nodes, weights=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)