-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add user callback to vf2_subgraph_mono
to potentially stop search before each check.
#280
base: develop
Are you sure you want to change the base?
Conversation
@@ -44,7 +44,8 @@ <h1> | |||
typename SubGraphIsoMapCallback> | |||
bool vf2_subgraph_iso(const GraphSmall& graph_small, | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -773,6 +779,10 @@ namespace detail | |||
bool found_match = false; | |||
|
|||
recur: | |||
if (!user_step_callback()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.