Find nearest edge in graph

前端 未结 5 1158
慢半拍i
慢半拍i 2021-02-04 02:43

I want to find the nearest edge in a graph. Consider the following example: \"yellow:

5条回答
  •  萌比男神i
    2021-02-04 03:33

    A very simple solution (but maybe not the one with lowest complexity) would be to use a quad tree for all your edges based on their bounding box. Then you simply extract the set of edges closest to your query point and iterate over them to find the closest edge.

    The extracted set of edges returned by the quad tree should be many factors smaller than your original 15 million edges and therefore a lot less expensive to iterate through.

    A quad tree is a simpler data structure than the R-tree. It is fairly common and should be readily available in many environments. For example, in Java the JTS Topology Suite has a structure QuadTree that can easily be wrapped to perform this task.

提交回复
热议问题