lib/networkx/graph.rb
# Adds multiple nodes to the graph
#
# @example Adds multiple nodes with attribute 'type'
#   graph.add_nodes([["Noida", type: "city"], ["Kgp", type: "town"]])
#
# @param nodes [Array<Object, Hash{ Object => Object }>] the Array of pair containing nodes and its attributes
Adds multiple nodes to the graph
Adds multiple nodes to the graph
def add_nodes(nodes)
      case nodes
      when Set, Array
        nodes.each { |node, **node_attrs| add_node(node, node_attrs) }
      else
        raise ArgumentError, 'Expected argument to be an Array or Set of nodes, '\
                             "received #{nodes.class.name} instead."
      end
    end
def add_nodes ( nodes ) case nodes when Set , Array nodes . each { | node , ** node_attrs | add_node ( node , node_attrs ) } else raise ArgumentError , 'Expected argument to be an Array or Set of nodes, ' "received #{nodes.class.name} instead." end end
Adds multiple nodes to the graph
Adds multiple nodes to the graph
nodes
the Array of pair containing nodes and its attributes
the Array of pair containing nodes and its attributes
example
Adds multiple nodes with attribute 'type' graph.add_nodes([["Noida", type: "city"], ["Kgp", type: "town"]])
Adds multiple nodes with attribute ' type ' graph . add_nodes ( [[ " Noida " type : " city " ] [ " Kgp " type : " town " ]] )