Add user callback to vf2_subgraph_mono to potentially stop search before each check.#280
Add user callback to vf2_subgraph_mono to potentially stop search before each check.#280cqc-alec wants to merge 3 commits intoboostorg:developfrom
vf2_subgraph_mono to potentially stop search before each check.#280Conversation
| const GraphLarge& graph_large, | ||
| SubGraphIsoMapCallback user_callback) | ||
| SubGraphIsoMapCallback user_callback, | ||
| bool(*user_step_callback)() = &vf2_trivial_step_callback) |
There was a problem hiding this comment.
Instead of being a concrete function pointer, this should be a template like most other parameters. That way, users can pass in whatever they like: lambda, function object, etc.
| bool found_match = false; | ||
|
|
||
| recur: | ||
| if (!user_step_callback()) { |
There was a problem hiding this comment.
I think this callback should take in whatever data might change between each call to it. Even though in your case you'll ignore it, someone else might have a reason to examine the internals of whatever state is changing. I guess it's just that s object?
|
Looks great so far! Thanks for keeping it simple, sorry it took me so long to take a look. I just made a couple of requests for changes. |
|
Thank you for the review Jeremy! I have actually switched to a different solution now, so no longer need this. I may come back to it anyway if you or others think it generally useful, though I cannot prioritize it just now. So, feel free to close, complete or leave open this PR as you see fit. By the way, the reason I didn't use a template type for the callback was that I couldn't see how to do so while maintaining backward compatibility (i.e. how to set a no-op default value). I guess an alternative would be to overload the whole function. |
|
OK, no worries. I'll leave this open for a while in case someone else needs the same functionality and wants to finish it off. |
|
I wonder if it's time to close this now @jeremy-murphy ? |
I still think it's a good idea, so I'll finish it off one day if you don't. :) |
OK! |
Also update documentation and add tests.
See the discussion on #271 .
Remarks:
vf2_subgraph_mono, notvf2_subgraph_iso, but it should be simple to do the same thing there too if desired.