在本专栏中,会陆续总结最近一段时间在路线规划和最短距离领域的学习与工程实践经验,包括如下内容:
1. 常见的路径规划开源项目和开源数据,比如OpenStreetMap, GraphHopper等
2. 常见的最短路径算法及其代码实现
最短路径算法是图论里经典的算法问题,回顾最短路径算法的发展历史以及各种算法的适用场景。并着重介绍大吞吐量高并发场景下的路径规划算法。
a. Dijkstra算法最为基础,heap性能在Dijkstra里非常重要,介绍heap的一些开源实现;
b. 大吞吐量路径规划场景中的Contraction Hierarchies(CH)算法,以及能够响应路网实时变化的Customizable Contraction Hierarchies(CCH)算法;
c. CH算法与TNR(Transite Node Routing)算法结合;
3. 最短距离Hub Labeling (HL)类算法及其代码实现
最短路径求解后,可以得到最短距离;但性能往往性能不如直接求解最短距离。在一些场景中,往往只需要最短距离而不需要最短路径,HL类算法性能可高达10M/s以上的性能,是最快路径规划算法的几百倍。
a. 复杂图中的Pruned Landmark Labeling (PLL)算法
b. 路网图中的Hierarchical Hub Labelings(HHL)算法
c. 在无向图里性能更高的Hierarchy 2-Hop-Labeling(H2H)算法
4. 10K*10K 距离矩阵计算的算法及代码实现
在一些规划场景中,需要几万个点(经纬度)之间的两两距离作为输入。
这里将介绍距离矩阵算法,单机秒级计算出这上亿甚至上十亿的距离。
5. 空间索引及开源实现
给定经纬度,如何快速定位其最近的线,最近的polygon;介绍二维空间索引,R-Tree, KD-Tree,Grid(geohash、google s2、uber h3) 等。
不定期更新。