|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.olduvai.treejuxtaposer.Tree2Tree
class Tree2Tree
Tree2Tree does the precomputation for each pair of trees. The two precomputation tasks are computing the best corresponding node for each node and building the range query data structures.
Tree
,
RangeList
Nested Class Summary | |
---|---|
private class |
Tree2Tree.NodeScorePair
Container class for returning best corresponding node+score pair. |
private class |
Tree2Tree.TmpD
Attachment to a node that is needed as temporary data structure when computing best corresponding nodes. |
Field Summary | |
---|---|
private java.util.Hashtable |
A2B
Subtree hashtable for A->B. |
private java.util.Hashtable |
B2A
Subtree hashtable for B->A. |
private java.util.Vector |
bestA2B
Vector for A->B that stores the best corresponding nodes for different levels. |
private java.util.Vector |
bestB2A
Vector for B->A that stores the best corresponding nodes for different levels. |
private float |
epsilon
Minimum edge weight if they are used. |
private int |
SubtreeLeafCutoff
Restriction on the maximum number of nodes to store for any subtree's forest of best corresponding nodes. |
private Tree |
treeA
Arbitrary tree A for this comparison. |
private Tree |
treeB
Arbitrary tree B for this comparison. |
Constructor Summary | |
---|---|
Tree2Tree(Tree t1,
Tree t2,
int edgeweightLevels)
Initialize the two vectors |
Method Summary | |
---|---|
private void |
addNodeToForest(TreeNode node,
java.util.ArrayList array,
java.util.Hashtable hash)
Adds the node to the hashtable, indexed by its key (as an Integer). |
private Tree2Tree.NodeScorePair |
computeBestMatch(TreeNode sourceNode,
Tree sourceTree,
Tree targetTree,
float edgeCoefficient,
Tree2Tree.TmpD[] tmpData)
Compute the best match for sourceNode from sourceTree in the targetTree. |
private void |
computeForest(java.util.Hashtable X2Y,
Tree treeX,
Tree treeY,
AccordionTreeDrawer atdY,
int cutoff)
Compute the forest of marked nodes in treeY, for subtrees under every node in treeX. |
protected TreeNode |
getBestCorrNode(Tree source,
TreeNode n,
Tree other,
int el)
Computes the node in Tree "other" whose set of descendant leaves best matches that of TreeNode n in Tree "source" The best match is the node n' maximizing the following score | S(n) Intersection S(n') | / | S(n) Union S(n') | where S(n) is the set of leaves that are descendants of node n. |
protected float |
getBestCorrNodeScore(Tree source,
TreeNode n,
Tree other,
int el)
Identify input trees as treeA or treeB and look up the best score
from the BCN of the input node from A to tree B. |
private Tree2Tree.NodeScorePair |
getBestNodeScorePair(TreeNode sourceNode,
Tree sourceTree,
Tree targetTree,
Tree2Tree.TmpD[] tmpData)
Find the best corresponding node for a given node sourceNode:sourceTree, in the target tree targetTree. |
protected java.util.ArrayList |
getCorrRange(Tree source,
TreeNode n,
Tree other,
int el)
Identify input trees as treeA or treeB and look up the best matching nodes
of the input node from A in tree B. |
private void |
onewayTreeCompare(Tree t1,
Tree t2,
java.util.Vector v12,
int edgeweightLevels)
For each node on Tree t1, computes the best matching node in Tree t2 and stores it in Vector v12. |
private java.util.ArrayList |
reduceNodeListToCutoff(java.util.ArrayList node,
int cutoff)
Return an ArrayList of a reduced number of elements from ArrayList based on the number of leaves; bigger subtrees are kept, ties broken by taking any subtree with maximum number of leaves not already in forest. |
private void |
removeNodeFromForest(TreeNode node,
java.util.ArrayList array,
java.util.Hashtable hash)
Removes the node from the hashtable, indexed by its key (as an Integer). |
protected void |
subtree2Forest(AccordionTreeDrawer atdA,
AccordionTreeDrawer atdB,
int eL)
Preprocessing: calculate and store forests that correspond to subtrees. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Tree treeA
private Tree treeB
private java.util.Hashtable A2B
SubtreeLeafCutoff
.
private java.util.Hashtable B2A
SubtreeLeafCutoff
.
private java.util.Vector bestA2B
private java.util.Vector bestB2A
private final float epsilon
private final int SubtreeLeafCutoff
Constructor Detail |
---|
public Tree2Tree(Tree t1, Tree t2, int edgeweightLevels)
t1
- Tree A/1 of this comparison object.t2
- Tree B/2 of this comparison object.edgeweightLevels
- The number of edge weight levels used in the comparisons. Defaults to 1 if not specified.Method Detail |
---|
private void addNodeToForest(TreeNode node, java.util.ArrayList array, java.util.Hashtable hash)
node
- Node to insert.array
- Array of integers, storing list of keys found in the hashtable.hash
- Lookup table for nodes, indexed by their key.private void removeNodeFromForest(TreeNode node, java.util.ArrayList array, java.util.Hashtable hash)
node
- Node to remove.array
- Array of integers, storing list of keys found in the hashtable.hash
- Lookup table for nodes, indexed by their key.private java.util.ArrayList reduceNodeListToCutoff(java.util.ArrayList node, int cutoff)
node
- List of nodes that would be marked (forest) if a subtree is marked (referenced by marking the root of this subtree).cutoff
- Limit on number of nodes stored for each subtree. Currently uses SubtreeLeafCutoff
defined value.
private void computeForest(java.util.Hashtable X2Y, Tree treeX, Tree treeY, AccordionTreeDrawer atdY, int cutoff)
SubtreeLeafCutoff
) to prevent
storage of each node for large subtrees; results for descendants fill in missing
values as needed.
X2Y
- BCN forest table for treeX to treeY (input empty, filled by this function).treeX
- First tree, each node in this tree is processed into a forest.treeY
- Second tree, nodes are located that match under subtree of node in treeX, and stored in the BCN table.atdY
- Drawer for treeY.cutoff
- Cutoff value for forest size, currently set to SubtreeLeafCutoff
.protected void subtree2Forest(AccordionTreeDrawer atdA, AccordionTreeDrawer atdB, int eL)
atdA
- Drawer for tree A.atdB
- Drawer for tree B.eL
- number of edge weight levels to compute (not used).protected TreeNode getBestCorrNode(Tree source, TreeNode n, Tree other, int el)
source
- Source tree that contains the node being looked up in the other tree.n
- Node being looked up in the target tree.other
- Target tree to find the best node for the input node.el
- Edge length weight to use for lookup.Tree
,
TreeNode
,
Tree2Tree.NodeScorePair
protected float getBestCorrNodeScore(Tree source, TreeNode n, Tree other, int el)
treeA
or treeB
and look up the best score
from the BCN of the input node from A to tree B.
source
- Tree that contains the target node.n
- The target node.other
- Second tree, for identifying the appropriate hashmap (either bestA2B
or bestB2A
).el
- The edge weight length to use for lookups.
protected java.util.ArrayList getCorrRange(Tree source, TreeNode n, Tree other, int el)
treeA
or treeB
and look up the best matching nodes
of the input node from A in tree B.
source
- Tree that contains the target node.n
- The target node.other
- Second tree, for identifying the appropriate hashmap (either bestA2B
or bestB2A
).el
- The edge weight length to use for lookups.
private void onewayTreeCompare(Tree t1, Tree t2, java.util.Vector v12, int edgeweightLevels)
t1
- The first treet2
- The second treev12
- Vector to store the hashmaps (t1:t2 and t2:t1) for matching node pairs for T1 vs T2. Each edge level has a hashmap of node-node pairs in the vector.edgeweightLevels
- Number of edge weight levels to storeTree
,
computeBestMatch(TreeNode, Tree, Tree, float, net.sourceforge.olduvai.treejuxtaposer.Tree2Tree.TmpD[])
,
Tree2Tree.NodeScorePair
private Tree2Tree.NodeScorePair getBestNodeScorePair(TreeNode sourceNode, Tree sourceTree, Tree targetTree, Tree2Tree.TmpD[] tmpData)
computeBestMatch(TreeNode, Tree, Tree, float, net.sourceforge.olduvai.treejuxtaposer.Tree2Tree.TmpD[])
.
How to compute the best corresponding node for each node:
node B is the best corresponding node of node A if it maximizes
| L(A) U L(B)|
----------------
| L(A) n L(B)|
where L(A),L(B) represent the set of leaves underneath the
node A and node B respectively.
For the description of the algorithm, see
Li Zhang. On Matching Nodes in Two Trees.
sourceNode
- Node of interest in sourceTree, get the corresponding Tree2Tree.NodeScorePair
in targetTree.sourceTree
- Tree that has sourceNode.targetTree
- Tree to look up a corresponding node, wrt to sourceNode.tmpData
- Array initialized by level 0 processing (getBestNodeScorePair(TreeNode, Tree, Tree, net.sourceforge.olduvai.treejuxtaposer.Tree2Tree.TmpD[])
), used to compute best nodes.
Tree2Tree.NodeScorePair
that best corresponds to sourceNode.private Tree2Tree.NodeScorePair computeBestMatch(TreeNode sourceNode, Tree sourceTree, Tree targetTree, float edgeCoefficient, Tree2Tree.TmpD[] tmpData)
getBestNodeScorePair(TreeNode, Tree, Tree, net.sourceforge.olduvai.treejuxtaposer.Tree2Tree.TmpD[])
,
which also initializes the arrays used in this function.
sourceNode
- Node of interest in sourceTree, get the corresponding Tree2Tree.NodeScorePair
in targetTree.sourceTree
- Tree that has sourceNode.targetTree
- Tree to look up a corresponding node, wrt to sourceNode.edgeCoefficient
- Edge level coefficient. Non-zero as level 0 is done in getBestNodeScorePair(TreeNode, Tree, Tree, net.sourceforge.olduvai.treejuxtaposer.Tree2Tree.TmpD[])
.tmpData
- Array initialized by level 0 processing (getBestNodeScorePair(TreeNode, Tree, Tree, net.sourceforge.olduvai.treejuxtaposer.Tree2Tree.TmpD[])
), used to compute best nodes.
Tree2Tree.NodeScorePair
that best corresponds to sourceNode.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |