Optimizations to the dictionary comparison strategy - #51
Merged
Merged
Conversation
pull Bot
pushed a commit
to bbhunter/graphtage
that referenced
this pull request
Sep 9, 2026
The bipartite matching description covered only `--dict-strategy match`, which stopped being the default in PR trailofbits#51. Describe `auto`, `match`, and `none`, and say which one is the default. Add a section on `--ignore-list-order`, which builds `UnorderedListNode` rather than `ListNode`, and give the complexity trade-off from the `BuildOptions.ignore_list_order` docstring. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GypKU5KdLfs2Cf8kS2TzJa
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Take these two JSON files as an example:
By default Graphtage used to try all possible matchings between dictionary key/value pairs; comparing
graphtage f1.json f2.jsonwould result in the "foo" key being replaced by "bar" and the "f" in the "oof" key being moved to the front of the string.This sort of matching is polynomial time in the size of the input, but often is still intractable for large files. Therefore, Graphtage had an option,
--no-key-editsor-kthat would prevent two dictionary key/value pairs from being compared to each other unless their keys were identical.graphtage -k f1.json f2.jsonwould have resulted in the2being replaced by"two", the entire "oof" key/value pair being removed, and the entire "foo" key/value pair being added.This PR…
--dict-strategy/-dsoption which sets the strategy:matchfor the old default behavior andnonefor the old--no-key-editsbehavior. The--no-key-editsoption still exists, but now is an alias to--dict-strategy none.--dict-strategy auto, which is now the default, that behaves exactly the same as thematchstrategy, but in the event that two key/value pairs have then exact same key, then they are automatically matched.graphtage --dict-strategy auto f1.json f2.jsonwill now result in2being replaces with"two",oofbeing replaced bybar, and"two"being replaced by2.