我在多维空间中有大量的点。我想找到几个邻居(在附近)任何给定的点(要求是为了避免扫描所有点)。查找大集合中的nearset邻居
我想知道如果我的解决办法是适当的:
预处理:
- 定义设置的ortogonal轴系
- 使每个点的投影每个轴上
- 每个投影都与从轴(键)的起点到点(值)的标识符的距离相关联。 指数预测 - 把所有的人都到有序set(如树集)
dist = distance of projection to the start point of axis point_num = number of point sorted_set.put(dist, point_num)
找到任何给定的点的邻居:
- 查找其投射在每个轴上
- 使用idexes - 在每个exis上查找最近投影数
- 查找实际的邻居 - 相交所有的导致
dx = radius of neighborhood (some constant) dist_1 = distance of projection of given point to start point of axis_1 list_1 = sorted_set_1.get_sub_set(dist_1 - dx, dist_1 + dx) dist_2 = distance of projection of given point to start point of axis_2 list_2 = sorted_set_2.get_sub_set(dist_2 - dx, dist_2 + dx) return intersection_of(list_1, list_2)
下面是一个简单的例子:
相交[2, 4, 1]
和[4, 5]
产生回答[4]
请点我,如果我在我的算法来实现任何错误
感谢
“2.对每个轴上的每个点进行投影”如何避免扫描所有需要的点? – AndyG 2013-02-15 16:11:06
预处理将只进行一次(在红黑树的情况下,复杂度为O(N * lg(N))作为索引的基础结构) - 所以这对我来说不是问题。但是发现邻居是非常频繁的操作,所以我不想每次扫描所有点时,找到每个给定点的邻居。 – stemm 2013-02-15 16:19:47
你看过K-D树吗? http://en.wikipedia.org/wiki/K-d_tree – AndyG 2013-02-15 16:21:24