Graph.add_node
-
Graph.
add_node
(key, 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 typeint
is automatically generated.attr_dict (dict, optional) – Vertex attributes, defaults to
None
.kwattr – Other named node attributes, defaults to an empty dict.
- Returns
str – 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
>>>