Repository navigation
Fix edge case in ISMAGS symmetry detection - #8055
Merged
Merged
Conversation
Co-authored-by: Peter Kroon <[email protected]>
rossbar
approved these changes
May 24, 2025
rossbar
left a comment
Contributor
There was a problem hiding this comment.
This essentially ports over the fix from marrink-lab/vermouth-martinize#338 . I'm no ISMAGs expert, but given the discussion over there this seems like a reasonable fix. Thanks for hunting it down @Peiffap !
Member
Author
|
There are some other changes in the original repo where its implementation has diverged, but they're fairly minor. Would synchronizing the two be something to do here or in a separate PR? |
amcandio
reviewed
May 25, 2025
amcandio
approved these changes
May 26, 2025
dschult
approved these changes
May 26, 2025
dschult
left a comment
Member
There was a problem hiding this comment.
Let's do the other changes in a separate PR. (I'm not actually sure what those other changes would be, but we've got approvals here, so let's get these in. :)
amcandio
pushed a commit
to amcandio/networkx
that referenced
this pull request
Jul 20, 2025
* Fix edge case in ISMAGS symmetry detection Co-authored-by: Peter Kroon <[email protected]> * Add viz to ISMAGS edge case test --------- Co-authored-by: Peter Kroon <[email protected]>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4915.
Paraphrasing the original issue (#4915): there is an error in the ISMAGS implementation. For some specific cases it trips an
AssertionError. This happens for graphs of this shape, where all nodes and edges are equivalent.During symmetry detection/analysis, nodes 0 and 3 are coupled and no longer equivalent. At that point, {4, 8} and {12, 16} are no longer equivalent, and neither are {5, 9} and {13, 17}. Coupling 4 then refining results in 5 and 9 getting their own partitions, but not 13 and 17.
This results in tripping the following
assert:networkx/networkx/algorithms/isomorphism/ismags.py
Lines 1090 to 1092 in 6791918
The good news is that this case cannot result in new symmetries, so it can be safely changed to an
if not cond: return [], cosets.This fix is a straight port of the one in marrink-lab/vermouth-martinize@d5be20b, with permission from the original author.
It replaces the assertion by the aforementioned
ifblock and adds the minimal test case above (which fails on networkx/main) to the test suite.