Classes | Typedefs | Enumerations | Functions
Rose::EditDistance::TreeEditDistance Namespace Reference


Analysis to determine how to make one AST look like another.

Actually editing one tree have the same shape as another is, in many cases, nonsensical but the edit distance metric is nonetheless useful to determine the similarity of two trees. See Analysis::compute for details about how this analysis is implemented.

The way the analysis is used is like this:

using namespace Rose::EditDistance;
SgNode *ast1 = ...; // The first subtree
SgNode *ast2 = ...; // Second subtree
TreeEditDistance::Analysis ted; // Object for performing the analysis
ted.substitutionCost(0.0); // Adjust some parameters
ted.compute(ast1, ast2); // Run the analysis
double cost = ted.cost(); // Query some results

Or in one expression:

double cost = TreeEditDistance::Analysis() .substitutionCost(0.0) .compute(ast1, ast2) .cost();

The analysis object can be reused as many times as one likes by calling its compute method with different trees. The query methods always return the same results until the next call to compute.


class  Analysis
 Analysis object for tree edit distance. More...
struct  Edit
 A single edit operation. More...
class  SubstitutionPredicate
 Base class for substitution prediates. More...


typedef std::vector< EditEdits
 List of edit operations. More...


enum  EditType {
 Type of edit operation. More...


std::ostream & operator<< (std::ostream &, const TreeEditDistance::Edit &)

Typedef Documentation

List of edit operations.

Definition at line 78 of file TreeEditDistance.h.

Enumeration Type Documentation

Type of edit operation.


Insert a node from another tree.


Delete a node from this tree.


Substitute a node; same as an insert-delete pair.

Definition at line 60 of file TreeEditDistance.h.