Note

This is the documentation for the current state of the development branch of rustworkx. The documentation or APIs here can change prior to being released.

rustworkx.digraph_is_isomorphic#

digraph_is_isomorphic(first, second, /, node_matcher=None, edge_matcher=None, id_order=True, call_limit=None)#

Determine if 2 directed graphs are isomorphic

This checks if 2 graphs are isomorphic both structurally and also comparing the node data and edge data using the provided matcher functions. The matcher function takes in 2 data objects and will compare them. A simple example that checks if they’re just equal would be:

graph_a = rustworkx.PyDiGraph()
graph_b = rustworkx.PyDiGraph()
rustworkx.is_isomorphic(graph_a, graph_b,
                       lambda x, y: x == y)

Note

For better performance on large graphs, consider setting id_order=False.

Parameters:
  • first (PyDiGraph) – The first graph to compare

  • second (PyDiGraph) – The second graph to compare

  • node_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.

  • edge_matcher (callable) – A python callable object that takes 2 positional one for each edge data object. If the return of this function evaluates to True then the edges 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.

  • call_limit (int) – An optional bound on the number of states that VF2 algorithm visits while searching for a solution. If it exceeds this limit, the algorithm will stop and return False.

Returns:

True if the 2 graphs are isomorphic False if they are not.

Return type:

bool