rustworkx.is_isomorphic_node_match#
- is_isomorphic_node_match(first, second, matcher, id_order=True)[source]#
Determine if 2 graphs are isomorphic
This checks if 2 graphs are isomorphic both structurally and also comparing the node data using the provided matcher function. The matcher function takes in 2 node data objects and will compare them. A simple example that checks if they’re just equal would be:
graph_a = rustworkx.PyDAG() graph_b = rustworkx.PyDAG() rustworkx.is_isomorphic_node_match(graph_a, graph_b, lambda x, y: x == y)
Note
For better performance on large graphs, consider setting id_order=False.
- Parameters:
first – The first graph to compare. Can either be a
PyGraph
orPyDiGraph
.second – The second graph to compare. Can either be a
PyGraph
orPyDiGraph
. It should be the same type as the first graph.matcher (callable) – A python callable object that takes 2 positional one for each node data object. If the return of this function evaluates to True then the nodes passed to it are vieded as matching.
id_order (bool) – If set to
False
this function will use a heuristic matching order based on [VF2] paper. Otherwise it will default to matching the nodes in order specified by their ids.
- Returns:
True
if the 2 graphs are isomorphicFalse
if they are not.- Return type:
bool