Adds depth-first search and breadth-first search #40
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds an experimental library API for searchers: depth-first search and breadth-first search.
The current API proposal I ended up with is as follows
The main idea is that the search context can keep internal state (stack or queue and a bitset) and cache their construction and allocation between multiple searches. For example for all subsequent searches after the very first one we can simply re-use the allocated bitset and can re-use the stack or queue's internal allocations.
Open questions
clear
andset_start
be two separate functions or should it just be one function that automatically clears the internal state whenever a new start node is set? What are the pros and cons of this design decision?Once we get this API into the standard
libtinygraph.h
header we better have a solid interface figured out. The alternative is adding a separate experimental header just for searches.