graphscope.experimental.nx.Graph.add_node

Graph.add_node(node_for_adding, **attr)[source]

Add a single node node_for_adding and update node attributes.

Parameters
  • node_for_adding (node) – A node can be int or str object.

  • attr (keyword arguments, optional) – Set or change node attributes using key=value.

See also

add_nodes_from

Examples

>>> G = nx.Graph()  # or DiGraph
>>> G.add_node(1)
>>> G.add_node(2)
>>> G.number_of_nodes()
2

Use keywords set/change node attributes:

>>> G.add_node(1, size=10)
>>> G.add_node(3, weight=0.4, type='apple')

Notes

nx.Graph support int or str object of nodes.