-
Couldn't load subscription status.
- Fork 5k
[New Algorithm] Adding Myers Difference Algorithm #693
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
Conversation
This is a reference.
http://www.xmailserver.org/diff2.pdf
Thank you 🙏
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 love the well-commented code 👍
So far, I've done a partial read through and left a comment on how the MDA generates the edit graph. Could you address that?
Myers Difference Algorithm/README.md
Outdated
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.
This paragraph doesn't make sense. Could you reword it?
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.
These steps are hard to understand. It seems worthwhile to explain what the blue line, green dots, dotted lines, and red number represents, just to give the reader more context before diving into the steps.
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.
Thank you for reviewing.
Yes, it is necessary. Understanding edit graph is important for understanding MDA.
I'll add more explanation 👍
It just occurred to me that we have an article on finding the longest common subsequence already: https://github.com/raywenderlich/swift-algorithm-club/tree/master/Longest%20Common%20Subsequence
Could you check it out to see if it makes sense to add your ideas to the current topic?
I have known that there is an article for finding the LCS. (https://github.com/raywenderlich/swift-algorithm-club/tree/master/Longest%20Common%20Subsequence)
My topic, or MDA is faster than this algorithm. It runs for loop twice like below.
for i in self.characters { for j in other.characters { } }
I takes O(N * M) times for the worst case 😱
One more, the LCS algorithm can get only LCS.
But, if someone understand my topic MDA and Edit Graph, it can be extended to getting Diff command, like insert or delete, not only LCS.
This may make it easy that , for example, difference refreshing for UITableView or UICollectionView.
@kelvinlauKL
I mentioned about the difference between my article and LongestCommonSubsequence.
The major difference is calculation efficiency.
and I added some explanation about figure.
Thank you 🙏
Please 🙏
Anything else is required?
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.
Sorry for the wait! I took a look at this and ran this code on Swift 5. Runs as expected on Xcode 10.2.
Merging!
Checklist
Description
It seems that some algorithm finding shortest edit script are included in this. This Myers algorithm is same type algorithm. It improves calculation time and space, but simple.
Android's DiffUtil are implemented by Myers Algorithm. So it is practical.
To understand the mechanism is good and I hope this PR supports for that.
I also add the description about Edit Graph, it is useful for understand Myers Algorithm.
Thank you.