Skip to content

Conversation

@harenbergsd
Copy link

This PR is for letting get_subisomorphisms_vf2 accept a callback function. See: https://igraph.discourse.group/t/stop-subgraph-isomorphism-after-x-matches/185/4. This allows you to do things like stop the algorithm if you have hit a number of matches.

Copy link
Member

@ntamas ntamas left a comment

Choose a reason for hiding this comment

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

Seems good, apart from one thing: there is no need to pass result into the callback and there is no need to add the current mapping to result by default. The callback should not do anything apart from forwarding the mappings (after proper conversion) to the Python callback; if the user wants to store the subisomorphism, he can do so by appending the mapping to a list in the Python callback. So there's no need for the whole magic with the igraph_vector_t allocation and the copying in igraphmodule_i_Graph_get_subisomorphisms_vf2_callback_fn. This is consistent with how the callback behaves for the "normal" isomorphism function.

@harenbergsd
Copy link
Author

harenbergsd commented May 5, 2020

Hmm perhaps adding a callback to get_subisomorphisms_vf2 has little benefit. I think it's possible to use subisomorphic_vf2, as you can pass a callback and store results like you said (and have it continue processing indefinitely).

It seems like get_subisomorphisms_vf2 is just a convenience wrapper around subisomorphic_vf2. Unlike subisomorphic_vf2, it returns all the results without having to make your own callback. So there is probably no reason to have get_subisomorphisms_vf2 accept a call back unless it does something like return all the results. Otherwise, it is effectively the same as subisomorphic_vf2, right?

@ntamas
Copy link
Member

ntamas commented May 12, 2020

Hmmm, you are right, I did not notice that the callback was already implemented for subisomorphic_vf2(). You are right, get_subisomorphisms_vf2() is simply a convenience wrapper and there's no point in adding the callback interface to get_subisomorphisms_vf2().

I'm closing this PR; feel free to reopen if you disagree and you'd like to work on this further.

@ntamas ntamas closed this May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants