最短路径分析算法in PgRouting
2011-11-18 16:45
267 查看
最短路径分析算法inPgRouting
wangsh2011-11-18
PgRouting是开源路径分析算法库,其主要功能包含:
基于Dijkstra算法的最短路径(未使用启发式算法);
基于Astar算法最短路径:使用启发式算法求解大数据量路径算法;
基于Shooting-Star算法的最短路径:使用启发式算法接球转向限制;
旅行商算法(TSP):使用遗传算法求解(最多求解40个点);
计算驾车距离(Isolines)(没有找到相关代码)。
staticintcompute_shortest_path(char*sql,intstart_vertex,intend_vertex,booldirected,boolhas_reverse_cost,path_element_t**path,int*path_count)
//此处省略代码n行
ret=boost_dijkstra(edges,total_tuples,start_vertex,end_vertex,
directed,has_reverse_cost,
path,path_count,&err_msg);
staticintcompute_shortest_path_astar(char*sql,intsource_vertex_id,inttarget_vertex_id,booldirected,boolhas_reverse_cost,path_element_t**path,int*path_count)
//callingC++A*function
ret=boost_astar(edges,total_tuples,source_vertex_id-v_min_id,target_vertex_id-v_min_id,directed,has_reverse_cost,path,path_count,&err_msg);
staticintcompute_shortest_path_shooting_star(char*sql,intsource_edge_id,inttarget_edge_id,booldirected,boolhas_reverse_cost,path_element_t**path,int*path_count)
ret=boost_shooting_star(edges,total_tuples,source_edge_id,target_edge_id,directed,has_reverse_cost,path,path_count,&err_msg,e_max_id);
staticintsolve_tsp(char*sql,char*p_ids,
{
//此处省略代码n行
//使用gaul库解决最多40个网络节点旅行商问题
ret=find_tsp_solution(total_tuples,DISTANCE,ids,
source,&fit,err_msg);
//此处省略代码n行
}
参考资料
1.PgRouting:http://www.pgrouting.org/
2.PgRouting文档介绍http://www.davidgis.fr/documentation/pgrouting-1.02/
3.使用pgRouting进行路径分析http://blog.csdn.net/warrenwyf/article/details/57033604.OSGEOpgroutinghttp://download.osgeo.org/pgrouting/5.Windows编译http://www.pgrouting.org/docs/howto/build_on_windows.html6.运用pgrouting求解最短路径http://2007.foss4g.org/presentations/view.php?abstract_id=84
7.PostLBShttp://en.giswiki.net/wiki/PostLBS
8.测试数据地址:http://wiki.openstreetmap.org/wiki/Planet.osm
wangsh2011-11-18
PgRouting是开源路径分析算法库,其主要功能包含:
基于Dijkstra算法的最短路径(未使用启发式算法);
基于Astar算法最短路径:使用启发式算法求解大数据量路径算法;
基于Shooting-Star算法的最短路径:使用启发式算法接球转向限制;
旅行商算法(TSP):使用遗传算法求解(最多求解40个点);
计算驾车距离(Isolines)(没有找到相关代码)。
编译pgrouting(参考5)
我分析相关代码,并贴出核心部分:pgrouting最短路径核心算法基于bgl实现:
dijkstra.c:
staticintcompute_shortest_path(char*sql,intstart_vertex,intend_vertex,booldirected,boolhas_reverse_cost,path_element_t**path,int*path_count)
{
//此处省略代码n行
ret=boost_dijkstra(edges,total_tuples,start_vertex,end_vertex,
directed,has_reverse_cost,
path,path_count,&err_msg);
//此处省略代码n行
}
astar.c:
staticintcompute_shortest_path_astar(char*sql,intsource_vertex_id,inttarget_vertex_id,booldirected,boolhas_reverse_cost,path_element_t**path,int*path_count)
{
//此处省略代码n行
//callingC++A*function
ret=boost_astar(edges,total_tuples,source_vertex_id-v_min_id,target_vertex_id-v_min_id,directed,has_reverse_cost,path,path_count,&err_msg);
//此处省略代码n行
}
shooting_star.c
staticintcompute_shortest_path_shooting_star(char*sql,intsource_edge_id,inttarget_edge_id,booldirected,boolhas_reverse_cost,path_element_t**path,int*path_count)
{
//此处省略代码n行
ret=boost_shooting_star(edges,total_tuples,source_edge_id,target_edge_id,directed,has_reverse_cost,path,path_count,&err_msg,e_max_id);
//此处省略代码n行
}
tsp.c:
staticintsolve_tsp(char*sql,char*p_ids,
intsource,path_element_t*path)
{
//此处省略代码n行
//使用gaul库解决最多40个网络节点旅行商问题
ret=find_tsp_solution(total_tuples,DISTANCE,ids,
source,&fit,err_msg);
//此处省略代码n行
}
pgrouting是依赖bgl完成路径分析的,这也许就是bgl的强大之处,也许是到了深入学习bgl的时候了。
参考资料
1.PgRouting:
2.PgRouting文档介绍
3.使用pgRouting进行路径分析
7.PostLBS
8.测试数据地址:
相关文章推荐
- 最短路径算法—Dijkstra(迪杰斯特拉)算法分析与实现(C/C++)
- 最短路径算法的命令式、函数式版本对比分析
- 最短路径算法—Dijkstra(迪杰斯特拉)算法分析与实现代码(C/C++)
- 围住神经猫,迷宫最短路径算法分析
- 图的最短路径算法分析与总结
- 最短路径算法—Floyd(弗洛伊德)算法分析与实现(C/C++)
- 最短路径(五)—最短路径算法对比分析
- 最短路径算法—Dijkstra(迪杰斯特拉)算法分析与实现(C/C++)
- 最短路径算法—Dijkstra(迪杰斯特拉)算法分析与实现(C/C++)
- 最短路径算法对比分析
- 最短路径算法对比分析
- 最短路径算法—SPFA(Shortest Path Faster Algorithm)算法分析与实现
- 最短路径算法—Dijkstra(迪杰斯特拉)算法分析与实现(C/C++)
- 最短路径算法—Bellman-Ford(贝尔曼-福特)算法分析与实现(C/C++)
- 最短路径算法对比分析
- 最短路径算法—Bellman-Ford(贝尔曼-福特)算法分析与实现(C/C++)
- 最短路径算法—Floyd-Warshall算法分析与实现
- 最短路径算法—Bellman-Ford(贝尔曼-福特)算法分析与实现(C/C++)
- 最短路径分析算法in QGIS
- 算法分析与设计课程设计-Dijkstra最短路径算法