algorithm - 将 2D 点划分为 N 个区域,每个区域有 K 个相邻点

标签 algorithm cluster-analysis hierarchical-clustering

<分区>

如果在二维空间中有一组点,是否有一种算法可以将这些点分成 N 个“区域”,每个区域包含 K 个相邻点?

例如,假设要将这 20 个点聚类为 4 组,每组 5 个点。一个令人满意的解决方案可能如下所示:

enter image description here

动机:我正在尝试优化 visualization that loads lots of images into the browser .我计划在页面加载时加载非常低分辨率的图像,然后在用户放大该区域时提高该区域图像的分辨率。当然,我需要量化空间,所以如果用户直接滚动到上面示例的中间,我必须为 4 组中的每一组获取高分辨率图像。

console.log('stackoverflow wants code for posts with codepen links')

最佳答案

一个算法可以是这样的:

- get a triangulation of the points (for example: Delaunay Triangulation): D
- get a planar graph from D: G
- Then partition G into connected subgraphs with equal size k

对于最后一步 this solution简短易懂(来自 Theoretical Computer Science 网站):

Compute a constant degree spanning tree T of your graph, root it, and now greedily find subtrees of roughly size r, extract them, and repeat. Naturally, if there is no constant degree spanning tree, then the star example shown above demonstrates that this algorithm can fail.

关于algorithm - 将 2D 点划分为 N 个区域,每个区域有 K 个相邻点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47458593/

相关文章:

java - 在 java 中我们可以使用 list.remove(int index) 来删除该索引中的项目,如果列表很大而我们只能使用 long 来存储索引怎么办?

python - 在 Python 中识别一维和二维数据中的异常值 block

r - 使用 R 进行 K 中心聚类

r - 如何翻转pheatmap中的层次聚类节点

r - R中hclust使用的聚类算法是什么?

algorithm - 从分层路径创建序数值

algorithm - 如何按邻近度对集合中的对象进行分组?

用于混合数据类型(包括字符串)的 Java 矩阵库

perl - 如何在 Perl 中实现 QT(质量阈值)聚类?

Python:算法