This articlemay be too technical for most readers to understand. Pleasehelp improve it tomake it understandable to non-experts, without removing the technical details.(October 2021) (Learn how and when to remove this message) |
Incomputer science,M-trees aretree data structures that are similar toR-trees andB-trees. It is constructed using ametric and relies on thetriangle inequality for efficient range andk-nearest neighbor (k-NN) queries.While M-trees can perform well in many conditions, the tree can also have large overlap and there is no clear strategy on how to best avoid overlap. In addition, it can only be used fordistance functions that satisfy the triangle inequality, while many advanced dissimilarity functions used ininformation retrieval do not satisfy this.[1]

As in any tree-based data structure, the M-tree is composed of nodes and leaves. In each node there is a data object that identifies it uniquely and a pointer to a sub-tree where its children reside. Every leaf has several data objects. For each node there is a radius that defines a Ball in the desired metric space. Thus, every node and leaf residing in a particular node is at most distance from, and every node and leaf with node parent keep the distance from it.
An M-tree has these components and sub-components:
The main idea is first to find a leaf nodeN where the new objectO belongs. IfN is not full then just attach it toN. IfN is full then invoke a method to splitN. The algorithm is as follows:
Algorithm Insert Input: NodeN of M-TreeMT,Entry Output: A new instance ofMT containing all entries in originalMT plus
's routing objects or objectsifN is not a leafthen { /* Look for entries that the new object fits into */let be routing objects from's set of routing objectssuch thatif is not emptythen { /* If there are one or more entry, then look for an entry such that is closer to the new object */ }else { /* If there are no such entry, then look for an object with minimal distance from */ /* its covering radius's edge to the new object */ /* Upgrade the new radii of the entry */ } /* Continue inserting in the next level */return insert();else { /* If the node has capacity then just insert the new object */ifN is not fullthen {store() } /* The node is at full capacity, then it is needed to do a new split in this level */else {split() } }
If the split method arrives to the root of the tree, then it choose two routing objects fromN, and creates two new nodes containing all the objects in originalN, and store them into the new root. If split methods arrives to a nodeN that is not the root of the tree, the method choose two new routing objects fromN, re-arrange every routing object inN in two new nodes and, and store these new nodes in the parent node of originalN. The split must be repeated if has not enough capacity to store. The algorithm is as follow:
Algorithm Split Input: NodeN of M-TreeMT,Entry Output: A new instance ofMT containing a new partition.
/* The new routing objects are now all those in the node plus the new routing object */ let beNN entries ofifN is not the rootthen { /*Get the parent node and the parent routing object*/let be the parent routing object ofNlet be the parent node ofN } /* This node will contain part of the objects of the node to be split */ Create a new nodeN' /* Promote two routing objects from the node to be split, to be new routing objects */ Create new objects and. Promote() /* Choose which objects from the node being split will act as new routing objects */ Partition() /* Store entries in each new routing object */Store's entries inN and's entries inN'ifN is the current rootthen { /* Create a new node and set it as new root and store the new routing objects */Create a new root nodeStore and in }else { /* Now use the parent routing object to store one of the new objects */Replace entry with entry inif is no fullthen { /* The second routing object is stored in the parent only if it has free capacity */Store in }else { /*If there is no free capacity then split the level up*/split() } }
A range query is where a minimum similarity/maximum distance value is specified. For a given query object and a maximum search distance, the range queryrange(Q, r(Q)) selects all the indexed objects such that.[2]
Algorithm RangeSearch starts from the root node and recursively traverses all the paths which cannot be excluded from leading to qualifying objects.
Algorithm RangeSearchInput: NodeN of M-Tree MT,Q: query object,: search radius
Output: all the DB objectssuch that{letbe the parent object of nodeN;ifNis not a leafthen {for eachentry()inNdo {ifthen {Compute;ifthenRangeSearch(*ptr()),Q,); } } }else {for eachentry()inNdo {ifthen {Compute;if ≤thenadd to the result; } } }}k-nearest neighbor (k-NN) query takes the cardinality of the input set as an input parameter. For a given query object Q ∈ D and anintegerk ≥ 1, thek-NN query NN(Q, k) selects thek indexed objects which have the shortest distance from Q, according to the distance function d.[2]