Graph.nodes_where_predicate

Graph.nodes_where_predicate(predicate, data=False)[source]

Get nodes for which a certain condition or set of conditions is true using a lambda function.

Parameters
  • predicate (callable) – The condition you want to evaluate. The callable takes 2 parameters: the node identifier and the node attributes, and should return True or False.

  • data (bool, optional) – If True, yield the node attributes in addition to the node identifiers.

Yields

hashable | tuple[hashable, dict[str, Any]] – If data is False, the next node that matches the condition. If data is True, the next node and its attributes.

Examples

>>>