-
Notifications
You must be signed in to change notification settings - Fork 9
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
Rework _unify #129
Merged
Merged
Rework _unify #129
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Resolves #16 |
7e053a4
to
d2c268b
Compare
slabasan
approved these changes
Feb 15, 2024
Yejashi
pushed a commit
to TauferLab/thicket
that referenced
this pull request
Mar 6, 2024
* Replace _sync_nodes and _sync_nodes_frame * Perform union every time to correctly keep nodes up-to-date * Add unit test and add literal reader for test * Add docstring
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area-tests
Issues and PRs involving Thicket's automated tests
area-thicket
Issues and PRs involving Thicket's core Thicket datastructure and associated classes
priority-normal
Normal priority issues and PRs
status-ready-for-review
This PR is ready to be reviewed by assigned reviewers
type-bug
Identifies bugs in issues and identifies bug fixes in PRs
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.
Summary
Rework the
_unify
function to leverage theold_to_new
object returned bygraph.union()
to more cleanly keep track of node updates during the unification process. Currently we update everything afterwards using_sync_nodes_frame
, which requires some assumptions about the structure of the data. These implicit assumptions have resulted in bugs from our users. By leveraging the node map returned by the union function, we do not have to make any assumptions, which will reduce the amount of bugs we encounter.Changes
_unify
function_sync_nodes
and_sync_nodes_frame
Performance Impact
Where
n=len(thickets)
:The current code unify is approx
O(n+n)
for computing unionsn
and sync nodes time (approxn
). The new code adds a loop in each union step that makes the union block nowO(n^2)
. new-v2 and new-v3 are optimizations on the naive implementation of "new".Small study
Current data line of best fit is linear (
Y = 0.07X + -1.73
)New data line of best fit is nlog(n) (
Y = -123 + .5X*log_10(X)
). Empirically this is nlog(n) but if we had a worst case example at each size with n distinct graphs (improbable) I imagine it could actually fit n^2.