Skip to content

BUG: reverse the map returned by vf2pp functions - #8813

Merged
rossbar merged 3 commits into
networkx:mainfrom
dschult:reverse_vf2pp_map
Aug 4, 2026
Merged

rossbar merged 3 commits into
networkx:mainfrom
dschult:reverse_vf2pp_map

Conversation

@dschult

@dschult dschult commented Aug 2, 2026

Copy link
Copy Markdown
Member

Fixes #8810

The vf2pp functions (change recently in #8506) return the mapping from the subgraph to the graph instead of the graph to the subgraph. That breaks backward compatibility! Also, an advantage of mapping from the graph to the subgraph is that the keys of the dict are the nodes in the full graph that make an induced subgraph. And "fixing" vf2pp also brings it in line with the other algorithms in the isomorphism suite.

So: I have reversed the mapping that gets returned (put it back the way it was -- I never intended it to change).
I also added a test to ensure that the various isomorphism algorithms report the same direction for the mapping, and reversed the mapping for tests recently put into vf2pp with the wrong ordering.
And I adjusted the docs to reflect this change.

The diff for the 2nd commit is all in test_vf2pp.py and it just switches names SH and FH except in calls to the vf2pp functions. The separate commit is to simplify review. But it is still quite long...

I feel very lucky to have this reported before it was released. Thanks @wenwen-666

@dschult dschult added this to the 3.7 milestone Aug 2, 2026

@rossbar rossbar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a tricky one! Nice catch @wenwen-666 and thanks for the fix @dschult !

@rossbar
rossbar merged commit 2aecdbd into networkx:main Aug 4, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

vf2pp_isomorphism returns mappings in the reverse direction after #8506

2 participants