As far as I know, the python interface does not have a way to stop the algorithm (get_subisomorphisms_vf2) after finding a certain number of matches. Could this be added as a new option? It would be a useful as isomorphism can have combinatorial explosion of results. I’d be willing to work on it.
You are right, the Python interface does not support stopping the search yet; it is supported in the C interface via igraph_subisomorphic_function_vf2()
. In the Python interface, I would prefer not to create another method for this but simply to extend the argument list of get_subisomorphisms_vf2()
with an extra callback
argument. If the callback is present, we need to prepare a special callback in the C layer that simply invokes the Python callback and casts its return value to a Boolean. This special C callback can then be passed to igraph_subisomorphic_function_vf2()
.
This would all have to be done in the C code that binds igraph to Python (somewhere in src/graphobject.c
in the source code of the Python interface). If you are willing to work on it, let me know and I’ll be happy to help along the way and/or review your PR when it’s ready. Thanks in advance!
Sounds good, I’ll let you know if I need help, thanks.
@steve I am not sufficiently familiar with the Python interface of igraph, or with Python’s C interface to comment much on how this can be implemented, but I wanted to point out that there are already a few other functions that have such a callback argument, notably the motif finding ones. You may want to look at the implementation of those for inspiration.
Just in case someone looks at this in the future, we determined this functionality could already be achieved through a callback in the function subisomorphic_vf2.