C# Class FatAntelope.XDiff

The XDiff algorithm for doing an unordered comparison of two xml documents and flaging the changed, inserted and deleted nodes. A C# port, with some modifications, of the original X-Diff algorithm by Yuan Wang described here: http://pages.cs.wisc.edu/~yuanwang/xdiff.html The node matching logic uses the minimum-cost maximum flow algorithm when necessary, to find the minimum-cost bipartite mapping of the two trees. This gives an optimal matching of nodes between the two trees.
Mostra file Open project: CameronWills/FatAntelope

Public Methods

Method Description
Diff ( XTree tree1, XTree tree2 ) : void

Compare and match the two trees

Private Methods

Method Description
ConstructCostMatrix ( int distance, int matching1, int matching2, int nodeCount, int costMatrix ) : void

Construct a least cost matrix (of the flow network) based on the distance matrix

DiffAttributes ( XNode attributes1, XNode attributes2 ) : void

Diff and match two lists of attributes

DiffElements ( XNode node1, XNode node2 ) : void

Compare and match the two elements (and their children).

DiffTexts ( XNode texts1, XNode texts2 ) : void

Diff and match two lists of text nodes

Distance ( XNode node1, XNode node2, bool toRecord, int threshold ) : int

Calculate the editing distance between the two nodes (with caching)

DistanceAttributes ( XNode attributes1, XNode attributes2 ) : int

Calculate the editing distance between two lists of attributes

DistanceElements ( XNode node1, XNode node2, int threshold ) : int

Calculate the editing distance between two elements, up to a maximum threshold.

DistanceMatchList ( XNode nodes1, XNode nodes2, bool treeOrder ) : int

Compute the minimal editing distance between two lists of elements

DistanceTexts ( XNode texts1, XNode texts2 ) : int

Compute the editing distance between two groups of text nodes

DoMinimalMatching ( int distance, int matching1, int matching2 ) : int

Perform minimal-cost matching algorithm between two node lists

FindMinimalMatching ( int distance, int matching1, int matching2 ) : int

Perform minimal-cost matching between two node lists

MatchAny ( XNode nodes1, XNode nodes2, MatchType match ) : int

Randomly match nodes any nodes that are unmatched with other unmatched nodes

MatchEqual ( XNode nodes1, XNode nodes2, MatchType match ) : int

Set match for child nodes with equal hash values (equal sub-trees)

MatchFilter ( XNode elements1, XNode elements2, bool matched1, bool matched2 ) : int

Filter out matched elements (equal hashes).

MatchList ( XNode nodes1, XNode nodes2, bool treeOrder ) : void

Find minimal cost matching between two node lists; Record the matching info back to the trees.

SearchNegativeCircuit ( int nodeCount, int costMatrix, int pathMatrix, int circuit ) : int

Search for negative cost circuit in the least cost matrix.

SetMatching ( List nodes, MatchType match ) : void

Set the match for the given nodes.

SetMatching ( XNode node1, MatchType match ) : void

Set the match for the given node

SetMatching ( XNode node1, XNode node2, MatchType match ) : void

Set the match for the given nodes to each other.

SetUnmatched ( XNode nodes, MatchType match ) : int

Set the match for the given nodes if they do not have a matching node.

Method Details

Diff() public static method

Compare and match the two trees
public static Diff ( XTree tree1, XTree tree2 ) : void
tree1 XTree
tree2 XTree
return void