KD树和R树有什么区别?

发布于 2024-10-05 20:03:27 字数 56 浏览 5 评论 0原文

我看了KD树和R树的定义。在我看来,它们几乎是一样的。

KD树和R树有什么区别?

I looked at the definition of KD-tree and R-tree. It seems to me that they are almost the same.

What's the difference between a KD-tree and an R-tree?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

翻了热茶 2024-10-12 20:03:27

它们实际上是完全不同的。它们具有相似的目的(空间数据的区域查询),并且它们都是树(并且都属于包围体层次索引家族),但这就是它们的所有共同点。

  • R 树是平衡的,kd 树不是(除非批量加载)。这就是为什么 R 树更适合更改数据,因为 kd 树可能需要重建才能重新优化。
  • R 树是面向磁盘的。他们实际上将数据组织在直接映射到磁盘上表示的区域中。这使得它们在实际数据库和内存不足操作中更有用。 kd-trees 是面向内存的,并且放入磁盘页面并不简单
  • k-d-trees 在批量加载时很优雅(SingleNegationElimination 指出了这一点,值得称赞),而 R-trees 更适合< em>改变数据(尽管当与静态数据一起使用时,它们确实受益于批量加载)。
  • R 树不覆盖整个数据空间。空白区域可能会被发现。 kd 树总是覆盖整个空间。
  • kd-trees 将数据空间进行二元分割,R-trees 将数据划分成矩形。二元分裂显然是不相交的;虽然 R 树的矩形可能会重叠(这实际上有时是好的,尽管人们试图最小化重叠)
  • kd 树在内存中更容易实现,这实际上是它们的主要好处
  • R 树可以存储 矩形和多边形,kd树仅存储点向量(因为多边形需要重叠)
  • R树具有各种优化策略,不同的分割,批量加载,插入和重新插入策略等。kd
  • 树使用到作为边界的分离超平面的一维距离; R 树使用到边界超矩形的 d 维最小距离进行边界(它们还可以使用某些计数查询的最大距离来过滤真阳性)。
  • kd 树支持平方欧几里得距离和 Minkowski 范数,而 R 树也被证明支持大地距离(用于查找地理数据上的邻近点)。

They are actually quite different. They serve similar purpose (region queries on spatial data), and they both are trees (and both belong to the family of bounding volume hierarchy indexes), but that is about all they have in common.

  • R-Trees are balanced, k-d-trees are not (unless bulk-loaded). This is why R-trees are preferred for changing data, as k-d-trees may need to be rebuilt to re-optimize.
  • R-Trees are disk-oriented. They actually organize the data in areas that directly map to the on-disk representation. This makes them more useful in real databases and for out-of-memory operation. k-d-trees are memory oriented and are non-trivial to put into disk pages
  • k-d-trees are elegant when bulk-loaded (kudos to SingleNegationElimination for pointing this out), while R-trees are better for changing data (although they do benefit from bulk loading, when used with static data).
  • R-Trees do not cover the whole data space. Empty areas may be uncovered. k-d-trees always cover the whole space.
  • k-d-trees binary split the data space, R-trees partition the data into rectangles. The binary splits are obviously disjoint; while the rectangles of an R-tree may overlap (which actually is sometimes good, although one tries to minimize overlap)
  • k-d-trees are a lot easier to implement in memory, which actually is their key benefit
  • R-trees can store rectangles and polygons, k-d-trees only stores point vectors (as overlap is needed for polygons)
  • R-trees come with various optimization strategies, different splits, bulk-loaders, insertion and reinsertion strategies etc.
  • k-d-trees use the one-dimensional distance to the separating hyperplane as bound; R-trees use the d-dimensional minimum distance to the bounding hyperrectangle for bounding (they can also use the maximum distance for some counting queries, to filter true positives).
  • k-d-trees support squared Euclidean distance and Minkowski norms, while Rtrees have been shown to also support geodetic distance (for finding near points on geodata).
半世蒼涼 2024-10-12 20:03:27

R-treekd-trees 基于类似的想法(基于轴对齐区域的空间划分),但主要区别是:

  • 节点kd 树中的节点表示分离平面,而 R 树中的节点表示边界框。
  • kd 树将整个空间划分为多个区域,而 R 树仅划分包含感兴趣点的空间子集。
  • kd 树表示不相交的分区(点仅属于一个区域),而 R 树中的区域可能重叠。

(有很多类似的用于划分空间的树结构:四叉树、BSP 树、R* 树等)

R-trees and kd-trees are based on similar ideas (space partitioning based on axis-aligned regions), but the key differences are:

  • Nodes in kd-trees represent separating planes, whereas nodes in R-trees represent bounding boxes.
  • kd-trees partition the whole of space into regions whereas R-trees only partition the subset of space containing the points of interest.
  • kd-trees represent a disjoint partition (points belong to only one region) whereas the regions in an R-tree may overlap.

(There are lots of similar kinds of tree structures for partitioning space: quadtrees, BSP-trees, R*-trees, etc. etc.)

顾冷 2024-10-12 20:03:27

此答案中未提及的两者之间的主要区别是 KD 树仅在批量加载情况下有效。一旦构建完成,修改或重新平衡 KD 树就并非易事。 R 树不会受此影响。

A major difference between the two not mentioned in this answer is that KD-trees are only efficient in bulk-loading situations. Once built, modifying or rebalancing a KD-tree is non-trivial. R-trees do not suffer from this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文