Least cost path with multiple points

后端 未结 2 665
长发绾君心
长发绾君心 2021-02-10 19:27

I am trying to connect bivariate location points together to form a route. My points refer to fish locations, and so I need paths that only pass through water, and not the surro

2条回答
  •  没有蜡笔的小新
    2021-02-10 20:03

    You could use a minimum spanning tree, where the cost on each edge is a function of distance and other factors. In your case, set the weight to infinity if an edge crosses non-water, making sure it never gets used unless they are required at the end to connect the graph. If the graph is non-connected, you can run two or more minimum spanning trees on each disconnected group of points. See wikipedia for easily implemented algorithms, notably Prim's algorithm.

提交回复
热议问题