public class KD_Tree extends KD_TreeNode
KD_TreeNode for inserting and searching over tree values.
This class can be used to build a tree-like structure, representing arbitrary information.
Use this as the base node of any k-dimensional tree structure, to store child node, but without
any value itself. Node values are compared using SimpleMathCompare by default,
but you can change that through the setMetricEvaluator method.bucketSize, evaluator, mathCompare, nodeStatschildNodeKeys, childNodes, count, maxIndent, name, parent, value, valueType| Constructor and Description |
|---|
KD_Tree(int theBucketSize,
java.lang.String theValueType,
FunctionMetric metricEval,
EvaluateMathDef mathEval)
Create a new instance of KD_Tree.
|
KD_Tree(java.lang.String theName,
int theBucketSize,
java.lang.String theValueType,
FunctionMetric metricEval,
EvaluateMathDef mathEval)
Create a new instance of KD_Tree.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(KD_TreeNode treeNode)
Add the node to the tree.
|
void |
clearTree()
Clear the whole tree by removing all child nodes.
|
java.lang.Object |
clone()
Clone and return a copy of this object.
|
java.util.ArrayList<KD_TreeNode> |
search(java.lang.String nodeName,
MetricDataset dataset,
int k)
Search the tree and return the
k closest matches to the dataset. |
java.lang.String |
toString()
Return a string-based description of the node branch.
|
addToTree, getBestMatchIndex, getBestMatchNode, getBucketSize, getMathEvaluatorClass, getMetricEvaluatorClass, getNodeStats, search, setBucketSize, setMathEvaluator, setMetricEvaluator, setNodeStats, updateNodeStatsaddChildNode, addChildNode, clearChildNodes, getChildNode, getChildNodeDeep, getChildNodeKeys, getChildNodes, getChildNodeValue, getChildNodeValueDeep, getCount, getName, getParent, getValue, getValueType, hasChildNode, hasChildNodeDeep, hasChildNodes, hasChildNodeValue, hasChildNodeValueDeep, hasValue, isLeaf, maxDepth, nodesAtLevel, removeChildNode, setChildNodes, setChildNodes, setCount, setParent, setValue, toString, treeValueDeeppublic KD_Tree(int theBucketSize,
java.lang.String theValueType,
FunctionMetric metricEval,
EvaluateMathDef mathEval)
throws java.lang.Exception
theBucketSize - the tree node capacity.theValueType - the type of value that this node supports.metricEval - the evaluation function.mathEval - for simple math comparisons.java.lang.Exception - any error.public KD_Tree(java.lang.String theName,
int theBucketSize,
java.lang.String theValueType,
FunctionMetric metricEval,
EvaluateMathDef mathEval)
throws java.lang.Exception
theName - a unique name or ID for the tree.theBucketSize - the tree node capacity.theValueType - the tree value type.metricEval - the evaluation function.mathEval - for simple math comparisons.java.lang.Exception - any error.public java.util.ArrayList<KD_TreeNode> search(java.lang.String nodeName, MetricDataset dataset, int k) throws java.lang.Exception
k closest matches to the dataset.nodeName - name of the node if already in the tree.dataset - the dataset to compare with.k - the number of matches to return.KD_TreeNode nodes that are closest to the dataset parameter.java.lang.Exception - any error.public boolean add(KD_TreeNode treeNode) throws java.lang.Exception
treeNode - the node with a list of values of size dimSize.java.lang.Exception - any error.public void clearTree()
public java.lang.String toString()
public java.lang.Object clone()
clone in class KD_TreeNode