feat(mgf_dev): Commutative tree isomorphism checking #254
No reviewers
Labels
No labels
Compat/Breaking
Kind
Bad merge
Kind
Bug
Kind
Documentation
Kind
Enhancement
Kind
Feature
Kind
New language
Kind
Security
Kind
Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: mergiraf/mergiraf#254
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "197-commutative-isomorphism"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #197.
This is a rather expensive isomorphism checking algorithm, so
it's not meant to be integrated in the merge process.
The main algorithm isn't super readable. If you have suggestions to reformulate it, feel free to push directly to the branch (which I created in the official repo).
@ -335,0 +382,4 @@
.children
.iter()
.map(|child| (child.grammar_name, *child))
.collect();
This grouping of the children by type is likely not super useful to reduce the time complexity, because checking the equality of grammar types is the first thing we do at the beginning of the recursive method call anyway.
And
MultiMap
with its double hashing is not the most efficient data structure either...Yeah, so I've removed it for now.
feat: Commutative tree isomorphism checkingto feat(mgf_dev): Commutative tree isomorphism checkingHere's a couple of miscellaneous changes
test_
in test names a896e63b97@ -335,0 +360,4 @@
// two isomorphic leaves
t2.children.is_empty() && self.source == t2.source
} else if !self.children.is_empty()
&& (self.children.iter())
Shouldn't one check for an equal length here? I understand that the current form would rightfully ignore a trailing separator for example, but it can also incorrectly fail to reject two arrays just because the first couple of elements match. Well, an array in particular won't have this problem, since its closing delimiter (
]
) will fire a mismatch -- take anyCommutativeParent::without_delimiters
instead. Let me try to go and add a test case for this.Ah yes of course, because the zip function will truncate the longer list of children. Good catch!
The only reason I even found this case is that all the
if
s&&
s and||
s got really confusing, so I tried to enumerate all the possible cases by hand 😅 Let's see if I find anything else!Test added!
LangProfile
getters@ -335,0 +354,4 @@
}
// two isomorphic leaves
fn isomorphic_leaves(t1: &AstNode, t2: &AstNode) -> bool {
Copying my comment from
194cfd6cb1
here just in case it got missed:Sure, that makes sense!
zip
@ada4a is this good to go for you, apart from the conflict? (which mergiraf can solve, but I discovered #259)
@wetneb wrote in #254 (comment):
Sure! The resolution is perfectly sensible too.
Finally we have a reproduction of this, thank you very much! This happened quite often actually, but I never bothered to record it.
I pushed a merge with formatting already dealt with, so we can merge this now.