generic_multiedge_match#
- generic_multiedge_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. Potentially, the constructed edge_match function can be slow since it must verify that no isomorphism exists between the multiedges before it returns False.
- Parameters:
- attrstring | list
The edge attribute to compare, or a list of node attributes to compare.
- defaultvalue | list
When
attris a string,defaultis the default value for that edge attribute. Whenattris a list,defaultis a default value for all edge attributes or a list of length same asattrholding default values for each edge attributes.- opcallable | list
When
attris a string,opis the operator to use when comparing that attribute. Whenattris a list,opis an operator to use when comparing each edge attribute or a list of length same asattrholding operators to use when comparing values for each attribute.
- Returns:
- matchfunction
The customized, generic
edge_matchfunction.
Examples
>>> from operator import eq >>> from math import isclose >>> from networkx.algorithms.isomorphism import generic_node_match >>> nm = generic_node_match("weight", 1.0, isclose) >>> nm = generic_node_match("color", "red", eq) >>> nm = generic_node_match(["weight", "color"], [1.0, "red"], [isclose, eq])