Myers Diff と LCS アルゴリズム7 分で読める最終更新日:
テキスト&コード差分比較アルゴリズム:Myers Diff と LCS 完全解説
差分比較の数学的アルゴリズムを解説。左右分割ビューと統合ビューを切り替えて機密コードを安全にレビュー。
W
WEBioDD エンジニアリングチーム•100% ブラウザ内完結&ゼロトラスト
重要ポイント
- Myers アルゴリズムは O(ND) の計算量で2つのテキスト間の最短編集パスを見つけ出します。
- 文字単位の二次比較により、変更された行内部の具体的な変更文字を正確にハイライトします。
- 左右分割表示は構造比較に適しており、統合表示は Git パッチ形式と完全に一致します。
- ブラウザ内実行により、企業の機密ソースコードが外部サーバーに残る心配がありません。
100% In-Browser & Local Execution
コードとテキストの差分を比較する
行単位および単語単位での変更箇所をシンタックスハイライト付きで高精度に検出・比較。
- Myers Diff algorithm
- Split & unified views
- Character-level highlighting
- Whitespace toggle
01.The Myers Diff Algorithm & Shortest Edit Script
Published by Eugene W. Myers in 1986, the Myers Diff algorithm finds the minimum number of insertions and deletions (the Shortest Edit Script) required to transform string A into string B. By modeling text comparison as a directed acyclic graph (edit graph) on a 2D grid, the algorithm executes an O(ND) search where N is the total length and D is the edit distance.
02.Split Side-by-Side vs. Unified Diff Visualization
Split view places original and modified files in parallel columns, synchronizing scroll positions for structural comparisons. Unified view interleaves additions (+) and deletions (-) in a single column, which is the standard format used by Git patches (git diff).
How to Compare Code and Text Revisions
Step-by-step instructions to inspect code diffs.
1
Paste Original Text
Paste the original source code or text into the left editor pane.
2
Paste Modified Text
Paste the updated revision into the right editor pane.
3
Toggle Diff View
Switch between Split (side-by-side) and Unified view modes depending on your preference.
4
Review Character Highlights
Inspect colored red (deleted) and green (added) inline highlights.
Frequently Asked Questions
No. The Myers diff algorithm executes 100% locally in your browser memory.