Network.add_node

Network.add_node(key=None, attr_dict=None, **kwattr)[source]

Add a node and specify its attributes (optional).

Parameters
  • key (hashable, optional) – An identifier for the node. Defaults to None, in which case an identifier of type int is automatically generated.

  • attr_dict (dict, optional) – Vertex attributes, defaults to None.

  • kwattr – Other named node attributes, defaults to an empty dict.

Returns

hashable – The key of the node.

Notes

If no key is provided for the node, one is generated automatically. An automatically generated key increments the highest key in use by 1:

key = int(sorted(self.node.keys())[-1]) + 1

Examples

>>>