lib/networkx/graph.rb
# Adds a node and its attributes to the graph
#
# @example Add a node with attribute 'type'
#   graph.add_node("Noida", type: "city")
#
# @param node [Object] the node object
# @param node_attrs [Hash{ Object => Object }] the hash of the attributes of the node
Adds a node and its attributes to the graph
Adds a node and its attributes to the graph
def add_node(node, **node_attrs)
      if @nodes.key?(node)
        @nodes[node].merge!(node_attrs)
      else
        @adj[node] = {}
        @nodes[node] = node_attrs
      end
    end
def add_node ( node , ** node_attrs ) if @nodes . key? ( node ) @nodes [ node ] . merge! ( node_attrs ) else @adj [ node ] = { } @nodes [ node ] = node_attrs end end
Adds a node and its attributes to the graph
Adds a node and its attributes to the graph
node
the node object
the node object
node_attrs
the hash of the attributes of the node
the hash of the attributes of the node
example
Add a node with attribute 'type' graph.add_node("Noida", type: "city")
Add a node with attribute ' type ' graph . add_node ( " Noida " type : " city " )