categorical_node_match#
- categorical_node_match(attr, default)[source]#
Returns a comparison function for a categorical node attribute.
The value(s) of the attr(s) must be hashable and comparable via the == operator since they are placed into a set([]) object. If the sets from G1 and G2 are the same, then the constructed function returns True.
- Parameters:
- attrstring | list
The name of the categorical node attribute to compare, or a list of categorical node attributes to compare.
- defaultvalue | list
When
attris a string, the default value for that categorical node attribute. Otherwise, a list of default values for each node attributes.
- Returns:
- matchfunction
The customized, categorical
node_matchfunction.
Examples
>>> import networkx.algorithms.isomorphism as iso >>> nm = iso.categorical_node_match("size", 1) >>> nm = iso.categorical_node_match(["color", "size"], ["red", 2])