Блог пользователя DonnieDarko

Автор DonnieDarko, история, 6 лет назад, По-английски

If I want to build a graph when the input is a set of points
and an edge exists if the distance between two points is less than
some value x, what is the best way to construct the graph?

  • Проголосовать: нравится
  • +15
  • Проголосовать: не нравится

»
6 лет назад, # |
Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

In the worst case the desired graph will have edges. So you might as well check distance between each pair of points and construct said graph in .

  • »
    »
    6 лет назад, # ^ |
      Проголосовать: нравится +27 Проголосовать: не нравится

    Thanks man! and in the case that I do not want to build the graph, but put each "component" in a subset, Is there a better approach?

    • »
      »
      »
      6 лет назад, # ^ |
      Rev. 2   Проголосовать: нравится +8 Проголосовать: не нравится

      One (horrible) idea that comes to mind: put the points into square buckets of side . The points within a bucket are clearly linked together. Compute the convex hull in each bucket. Then find the closest distance between the points of a bucket and those of its 12 relevant neighbors with rotating callipers. Link them if that distance is  ≤ x.

»
6 лет назад, # |
  Проголосовать: нравится +42 Проголосовать: не нравится

You could conpute the Delaunay triangulation of the points and then consider only edges which correspont to adjacent faces. This works because the Euclidean MST is known to be a subgraph in this (planar) triangulation graph.