Beispiel #1
0
        private void AddChildToNode(MTreeElement <T> newChild, double newChildDist)
        {
            newChild.DistanceToParent = newChildDist;
            Children.Add(newChild);

            double newRadius = Math.Max(CoveringRadius, newChildDist + newChild.CoveringRadius);

            ExpandCoveringRadius(newRadius);

            Node <T> newNode = newChild as Node <T>;

            if (newNode != null)
            {
                newNode.SetNewParent(this);
            }
        }
Beispiel #2
0
        private void ChooseTwoNewReplacementNodes(out Node <T> node1, out Node <T> node2)
        {
            /* Uses M_LB_Dist method described in paper. This had the best trade
             * off between build time and search time when testing MTree with
             * 5,000,000 items.
             */

            MTreeElement <T> closestChild       = Children[0];
            double           distToClosestChild = Children[0].DistanceToParent;

            MTreeElement <T> farthestChild       = closestChild;
            double           distToFarthestChild = distToClosestChild;

            for (int i = 0; i < Children.Count; i++)
            {
                if (Children[i].DistanceToParent < distToClosestChild)
                {
                    distToClosestChild = Children[i].DistanceToParent;
                    closestChild       = Children[i];
                }

                if (Children[i].DistanceToParent > distToFarthestChild)
                {
                    distToFarthestChild = Children[i].DistanceToParent;
                    farthestChild       = Children[i];
                }
            }

            Children.Remove(closestChild);
            Children.Remove(farthestChild);

            node1 = new Node <T>(Tree, Parent, closestChild.Item, -1, false, IsLeaf);
            node1.AddChildToNode(closestChild, 0);

            node2 = new Node <T>(Tree, Parent, farthestChild.Item, -1, false, IsLeaf);
            node2.AddChildToNode(farthestChild, 0);
        }