在并行算法中包含对称信息(在图上)[关闭]

问题描述 投票:0回答:0

我有以下问题:

我有一组点。每个点都有一个唯一的 ID 和一个坐标 (x,y)。 我需要创建一种相邻图,即每个点都需要有一个 ID 数组,引用相邻点。具体来说,给定一个点 p 和一个半径 r,我需要从 p 找到半径 r 内的所有其他点。必须对所有点都这样做。

因此,一旦我发现p1的邻居是p2,当然反过来也是正确的。

我想并行解决这个问题。不考虑上面解释的对称性的愚蠢算法将>

vec_points is the vector of points
n_t = #threads

divide vec_points in n_t parts.
call a thread on each part. Each thread t takes slice and do:
  for each point p in slice:
     for each point p2 in vec_points:
        if p is close enough to p2:
           p.neighbors.push_back(p2)

这样做我得到了想要的结果,但当然我失去了对称操作:如果我在线程 1 的切片中有 p1 并且在 p2 的切片中有 p2 一旦我在线程 1 中找到 p1 我就不能简单地对该部分进行操作接近 p2.

我可以巧妙地使用对称概念甚至并行来加速我的算法?

multithreading parallel-processing graph-theory
© www.soinside.com 2019 - 2024. All rights reserved.