Skip to content

fix: correct result and mappings of VF2 functions with callback - #904

Draft
szhorvat wants to merge 1 commit into
igraph:mainfrom
szhorvat:fix/vf2-callback-result
Draft

szhorvat wants to merge 1 commit into
igraph:mainfrom
szhorvat:fix/vf2-callback-result

Conversation

@szhorvat

Copy link
Copy Markdown
Member

Graph.isomorphic_vf2() and Graph.subisomorphic_vf2() always returned False when a callback was given, because the callback variants of the C functions have no result argument and res was never set. They also passed the output mapping vectors to the C functions, which use them only as search workspace, so the returned mappings were meaningless (all -1 after a complete search, or empty).

The result is now True if the callback was called at least once. The mapping vectors are no longer passed to the C core; instead the callback copies each match into them, so the mappings returned are those of the last match passed to the callback, i.e. the one at which the callback stopped the search, or the last one found.

Assisted-by: Claude Opus 5.5

Graph.isomorphic_vf2() and Graph.subisomorphic_vf2() always returned
False when a callback was given, because the callback variants of the
C functions have no result argument and res was never set. They also
passed the output mapping vectors to the C functions, which use them
only as search workspace, so the returned mappings were meaningless
(all -1 after a complete search, or empty).

The result is now True if the callback was called at least once. The
mapping vectors are no longer passed to the C core; instead the
callback copies each match into them, so the mappings returned are
those of the last match passed to the callback, i.e. the one at which
the callback stopped the search, or the last one found.

Assisted-by: Claude Opus 5.5
@szhorvat
szhorvat marked this pull request as draft November 29, 2026 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant