networkx.algorithms.isomorphism.generic_node_match¶
-
generic_node_match
(attr, default, op)[source]¶ Returns a comparison function for a generic attribute.
The value(s) of the attr(s) are compared using the specified operators. If all the attributes are equal, then the constructed function returns True.
Parameters: - attr (string | list) – The node attribute to compare, or a list of node attributes to compare.
- default (value | list) – The default value for the node attribute, or a list of default values for the node attributes.
- op (callable | list) – The operator to use when comparing attribute values, or a list of operators to use when comparing values for each attribute.
Returns: match – The customized, generic
node_match
function.Return type: Examples
>>> from operator import eq >>> from networkx.algorithms.isomorphism.matchhelpers import close >>> from networkx.algorithms.isomorphism import generic_node_match >>> nm = generic_node_match('weight', 1.0, close) >>> nm = generic_node_match('color', 'red', eq) >>> nm = generic_node_match(['weight', 'color'], [1.0, 'red'], [close, eq])