forked from Qiskit/rustworkx
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround isomorphism failure with node removals
The dag_isomorphism module was forked from upstream petgraph to handle the PyDiGraph type and also to enable handling exceptions in the python check functions gracefully. However, when this was done it neglected that here were limitations with that module which causes failures in certain scenarios after node removals. This was because the upstream petgraph implementation was built on the Graph type instead of the StableGraph type. The only difference between these types is that StableGraph does not reuse indexes on removals but Graph does. This can cause there to be holes in the list of node ids. This breaks assumptions in multiple places of the VF2 implementation causing a panic if isomorphism checks are run on a PyDiGraph that has nodes removed. This commit worksaround this limitation by checking if we've removed nodes from the PyDiGraph object and if we have it iterates over the graph and clones it into a copy with a condensed set of node ids. This fix is less than ideal in that it results in a copy of the graph which will potentially have performance implications, especially for larger graphs. But after attempting to fix the VF2 implementation that seems to be a more involved project than I originally hoped. This will at least workaround the bug until a better more robust VF2 implementation can be written (and likely should be contributed back upstream to petgraph). Fixes Qiskit#27
- Loading branch information
Showing
3 changed files
with
146 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters