Repository navigation
fix optimize_edit_paths handling of self-loops - #8207
Merged
Merged
Conversation
…ubstitution is possible
rossbar
reviewed
Aug 27, 2025
rossbar
left a comment
Contributor
There was a problem hiding this comment.
I generally approve this change with the caveat that I don't have a complete understanding of the graph_edit_distance code and am heavily relying on the test suite here to catch unintended behavior changes. This definitely needs at least one more set of eyes!
Anyways, thanks for taking this on @albastardoto !
dschult
reviewed
Aug 28, 2025
dschult
force-pushed
the
bufix-for-issue-8188
branch
from
August 30, 2025 21:04
4c59377 to
4b19e00
Compare
optimize_edit_paths to delay self-loop removal only if substitutions are possible
optimize_edit_paths to delay self-loop removal only if substitutions are possibleoptimize_edit_paths handling of self-loops
alfred-mikhael
pushed a commit
to alfred-mikhael/networkx
that referenced
this pull request
Sep 3, 2025
* fixing match_edges edge_case to ensure it applies only when an edge substitution is possible * minor formatting change for tests Co-authored-by: Ross Barnowski <[email protected]> * implement suggestion to use precomputed values * Update networkx/algorithms/tests/test_similarity.py --------- Co-authored-by: Ross Barnowski <[email protected]> Co-authored-by: Dan Schult <[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.
My first ever contribution to an open source project !
bugfix for : nx.graph_edit_distance returns wrong value when one graph contains only one node and loops and the other graph is empty #8188
I added the previously failing tests to the test suite.
The fix was to only attempt to match edges after one node match has been made but only if it's possible that a substitution even exists. This "only if it's possible that a substitution even exists" was what was missing before. To check if a substitution is possible, there has to be at least one pending edge in both g and h.