ROSE
0.11.83.2

Analysis object for tree edit distance.
The Analysis object holds the settings and state for performing tree edit distance. See TreeEditDistance for details and examples.
Definition at line 95 of file TreeEditDistance.h.
#include <midend/programAnalysis/EditDistance/TreeEditDistance.h>
Public Member Functions  
Analysis ()  
Construct an analysis with default values. More...  
Analysis &  clear () 
Forget calculated results. More...  
double  cost () const 
Total cost for making one tree the same shape as the other. More...  
double  relativeCost () const 
Relative cost. More...  
Edits  edits () const 
Edit operations to make one path look like another. More...  
std::pair< SgNode *, SgNode * >  trees () const 
The two trees that were compared. More...  
std::pair< size_t, size_t >  graphSize () const 
Number of vertices and edges in the graph. More...  
void  emitGraphViz (std::ostream &) const 
Emit a GraphViz file. More...  
double  insertionCost () const 
Property: insertion cost. More...  
Analysis &  insertionCost (double weight) 
Property: insertion cost. More...  
double  deletionCost () const 
Property: deletion cost. More...  
Analysis &  deletionCost (double weight) 
Property: deletion cost. More...  
double  substitutionCost () const 
Property: substitution cost. More...  
Analysis &  substitutionCost (double weight) 
Property: substitution cost. More...  
SubstitutionPredicate *  substitutionPredicate () const 
Property: substitution predicate. More...  
Analysis &  substitutionPredicate (SubstitutionPredicate *predicate) 
Property: substitution predicate. More...  
Analysis &  compute (SgNode *source, SgNode *target, SgFile *sourceFile=NULL, SgFile *targetFile=NULL) 
Compute tree edit distances. More...  
Analysis &  compute (SgNode *target, SgFile *targetFile=NULL) 
Compute tree edit distances. More...  
Analysis &  compute () 
Compute tree edit distances. More...  
const std::vector< SgNode * > &  sourceTreeNodes () const 
List of nodes in the trees.  
const std::vector< SgNode * > &  targetTreeNodes () const 
List of nodes in the trees.  
Analysis &  setTree1 (SgNode *ast, SgFile *file=NULL) 
Change one tree or the other. More...  
Analysis &  setTree2 (SgNode *ast, SgFile *file=NULL) 
Change one tree or the other. More...  

inline 
Construct an analysis with default values.
Definition at line 121 of file TreeEditDistance.h.

inline 
Forget calculated results.
Causes the analysis to forget the trees being compared and previous results. Does not modify properties that affect the analysis operation (like the various edit costs).
Definition at line 129 of file TreeEditDistance.h.

inline 
Property: insertion cost.
The nonnegative cost of performing an insertion when editing one tree to make it look like another.
Definition at line 143 of file TreeEditDistance.h.

inline 
Property: insertion cost.
The nonnegative cost of performing an insertion when editing one tree to make it look like another.
Definition at line 146 of file TreeEditDistance.h.

inline 
Property: deletion cost.
The nonnegative cost of performing a deletion when editing one tree to make it look like another.
Definition at line 158 of file TreeEditDistance.h.

inline 
Property: deletion cost.
The nonnegative cost of performing a deletion when editing one tree to make it look like another.
Definition at line 161 of file TreeEditDistance.h.

inline 
Property: substitution cost.
The nonnegative cost of performing a substitution when editing one tree to make it look like another.
Definition at line 173 of file TreeEditDistance.h.

inline 
Property: substitution cost.
The nonnegative cost of performing a substitution when editing one tree to make it look like another.
Definition at line 176 of file TreeEditDistance.h.

inline 
Property: substitution predicate.
A substitution can only occur when the source and destination AST nodes are at the same depth in their respective subtrees, and when the substitution predicate returns true. The default predicate (when the pointer is null) always returns true, thus taking only tree shape into account when making one tree look like another.
Definition at line 190 of file TreeEditDistance.h.

inline 
Property: substitution predicate.
A substitution can only occur when the source and destination AST nodes are at the same depth in their respective subtrees, and when the substitution predicate returns true. The default predicate (when the pointer is null) always returns true, thus taking only tree shape into account when making one tree look like another.
Definition at line 193 of file TreeEditDistance.h.
Analysis& Rose::EditDistance::TreeEditDistance::Analysis::compute  (  SgNode *  source, 
SgNode *  target,  
SgFile *  sourceFile = NULL , 

SgFile *  targetFile = NULL 

) 
Compute tree edit distances.
Computes edit distances and stores them in this analysis. Most of the other methods simply query the results computed from this call.
Given two trees, source
and target
, compute and store within this object information about the edit distance from source
to target
. That is, the cost for editing source
to make it the same shape as target
. Applying edits to build such a tree is most likely nonsensical, but it gives a measure of similarity between two trees. If files sourceFile
and/or targetFile
are nonnull, then the Sg_File_Info of each node under source
and target
, respectively, are compared with the specified files and contribute to the edit distance only when that node belongs to the specified file.
Returns this analysis object so that queries can be chained, as in
There are three versions of this function:
This analysis uses Dijkstra's shortest path and takes a total of memory and where and are the number of nodes in the source and target trees and is the number of edges representing possible insertions, deletions, and substitutions.
Analysis& Rose::EditDistance::TreeEditDistance::Analysis::compute  (  SgNode *  target, 
SgFile *  targetFile = NULL 

) 
Compute tree edit distances.
Computes edit distances and stores them in this analysis. Most of the other methods simply query the results computed from this call.
Given two trees, source
and target
, compute and store within this object information about the edit distance from source
to target
. That is, the cost for editing source
to make it the same shape as target
. Applying edits to build such a tree is most likely nonsensical, but it gives a measure of similarity between two trees. If files sourceFile
and/or targetFile
are nonnull, then the Sg_File_Info of each node under source
and target
, respectively, are compared with the specified files and contribute to the edit distance only when that node belongs to the specified file.
Returns this analysis object so that queries can be chained, as in
There are three versions of this function:
This analysis uses Dijkstra's shortest path and takes a total of memory and where and are the number of nodes in the source and target trees and is the number of edges representing possible insertions, deletions, and substitutions.
Analysis& Rose::EditDistance::TreeEditDistance::Analysis::compute  (  ) 
Compute tree edit distances.
Computes edit distances and stores them in this analysis. Most of the other methods simply query the results computed from this call.
Given two trees, source
and target
, compute and store within this object information about the edit distance from source
to target
. That is, the cost for editing source
to make it the same shape as target
. Applying edits to build such a tree is most likely nonsensical, but it gives a measure of similarity between two trees. If files sourceFile
and/or targetFile
are nonnull, then the Sg_File_Info of each node under source
and target
, respectively, are compared with the specified files and contribute to the edit distance only when that node belongs to the specified file.
Returns this analysis object so that queries can be chained, as in
There are three versions of this function:
This analysis uses Dijkstra's shortest path and takes a total of memory and where and are the number of nodes in the source and target trees and is the number of edges representing possible insertions, deletions, and substitutions.
double Rose::EditDistance::TreeEditDistance::Analysis::cost  (  )  const 
Total cost for making one tree the same shape as the other.
This is the same value returned by the previous call to compute and also available by querying for the actual list of edits and summing their costs.
double Rose::EditDistance::TreeEditDistance::Analysis::relativeCost  (  )  const 
Relative cost.
This function returns an edit distance normalized to the size of the larger tree. It does so by simply dividing the total edit cost by the number of selected nodes in the larger tree.
Edits Rose::EditDistance::TreeEditDistance::Analysis::edits  (  )  const 
Edit operations to make one path look like another.
The two trees that were compared.
Definition at line 253 of file TreeEditDistance.h.
std::pair<size_t, size_t> Rose::EditDistance::TreeEditDistance::Analysis::graphSize  (  )  const 
Number of vertices and edges in the graph.
The graph is used to compute Dijkstra's shortest path and minimize the cost of the edits. This function returns the number of vertices and edges in the graph.
void Rose::EditDistance::TreeEditDistance::Analysis::emitGraphViz  (  std::ostream &  )  const 
Emit a GraphViz file.
Emits a GraphViz file of the graph used to compute the edit distance and the edit distance path. The rows of the graph represent nodes in the source AST and the columns represent nodes in the target AST. Note that the columns are not in the same order for each row because of limitations with the GraphViz "dot" program. Red edges represent deletion of a node in the source tree; green edges represent insertion of a node from the target tree; blue edges represent substitution of a node in the source tree with a node from the target tree; and black edges represent the edit path that was computed by the compute method.
The output file also contains invisible edges in an attempt to coerce "dot" into making a layout that is as close to being a matrix as possible.
Analysis& Rose::EditDistance::TreeEditDistance::Analysis::setTree1  (  SgNode *  ast, 
SgFile *  file = NULL 

) 
Change one tree or the other.
This function sets one of the two trees that are being compared without affecting the other.
Analysis& Rose::EditDistance::TreeEditDistance::Analysis::setTree2  (  SgNode *  ast, 
SgFile *  file = NULL 

) 
Change one tree or the other.
This function sets one of the two trees that are being compared without affecting the other.