Network.nodes_attribute

Network.nodes_attribute(name, value=None, keys=None)[source]

Get or set an attribute of multiple nodes.

Parameters:
namestr

The name of the attribute.

valueobj, optional

The value of the attribute.

keyslist[hashable], optional

A list of node identifiers.

Returns:
list[Any] | None

The value of the attribute for each node, or None if the function is used as a “setter”.

Raises:
KeyError

If any of the nodes does not exist.