Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Library for running tree diffs.

License

NotificationsYou must be signed in to change notification settings

Tchanders/treeDiffer.js

Repository files navigation

A JavaScript library for diffing trees in the browser, implementing the algorithm outlined in:http://epubs.siam.org/doi/abs/10.1137/0218082?journalCode=smjcat

This library forms the basis for visual diffs in Wikimedia'svisual editor.

treeDiffer finds the minimum transactions to get from the first tree to the second tree. Nodes in each tree are labelled inpost order, starting from 0. Each transaction is of the form [nodeToRemove, nodeToInsert], where nodeToRemove or nodeToInsert (but not both) can be null. E.g:

  • [1, null] indicates that node 1 was removed from the first tree
  • [null, 2] indicates that node 2 was inserted into the second tree
  • [3, 4] indicates that node 3 in the first tree was changed into node 4 in the second tree

The only allowed transactions are insert, remove and change; a move would be captured by a remove and an insert. See the above paper for more details.

Usage

Trees can be made of any type of node, as long as the nodes are connected in atree structure.

The abstract treeDiffer.treeNode class should be extended to work with the specific node type.

Demo

Using treeDiffer to diff HTML:https://tchanders.github.io/treeDiffer.js/

About

Library for running tree diffs.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors4

  •  
  •  
  •  
  •  

[8]ページ先頭

©2009-2026 Movatter.jp