all the nodes should be carectorized into three groups: (visited, front, unknown) we should pay special attention to front group.

The Dijkstra Algorithm:

front = start node

while front is not empty:

  get node n with minimum cost in the front group, and mark it as visited

  for any direct neighbour m of n, and not in the visited group:

    add it to front group if it is not in the front group

    or update (when the new cost is lower) its cost if it is in the front group

So in one loop:

1. only one node is added into visited group;

2. all the nodes directly connected with the visited group are added into front group;

3. update on some of the front nodes (connected with newly added nodes in visited), should be made.

  For 3, alternatively, we can just add the new nodes connected with the newly added visited node (not update, so may have copy of the same node in front). Then right after we add a visited node, we should "skip" the copy of this visited node in front group.

To improve the algorithm's efficiency, we can implement the front group by Heap data strucutre, instead of searching the minimum element in list with O(N) for each loop.

During each loop, we first pop the minimum node from front group and set it as visited, then we push back newly added front nodes connected with this new visited node, to reach a O(logN) complexity.

最新文章

  1. delphi dev 汉化
  2. TCP/IP之四书五经[转自2003.12程序员]
  3. 20145334实验三《敏捷开发与XP实践》
  4. PHP 开发环境配置
  5. typedef函数指针使用方法
  6. web自动化框架之一介绍与环境搭建(Selenium+Eclipse+Python)
  7. Activiti工作流引擎使用
  8. android中创建模拟器的 SDCard
  9. UVA 529 Addition Chains(迭代搜索)
  10. 一个基于JRTPLIB的轻量级RTSP客户端(myRTSPClient)——实现篇:(二)用户接口层之RtspClient类及其构造函数
  11. 2.Lucene3.6.2包介绍,第一个Lucene案例介绍,查看索引信息的工具lukeall介绍,Luke查看的索引库内容,索引查找过程
  12. 底层原理Hashmap源码解析实例
  13. Thread类中start()方法喝run()方法有什么不同?
  14. C++ 解析Json——jsoncpp(转)
  15. js的字符串代码库及讲解
  16. vue路由1:基本使用
  17. 2017 Russian Code Cup (RCC 17), Elimination Round D - Acute Triangles
  18. 分布式高性能消息系统(Kafka MQ)的原理与实践
  19. WPF中添加Winform用户自定义控件
  20. centos7数据库连接使用127.0.0.1报permission denied,使用localhost报No such file or directory

热门文章

  1. 解读ASP.NET 5 & MVC6系列(9):日志框架
  2. .NET跨平台之旅:在Linux上以本地机器码(native)运行ASP.NET Core站点
  3. 时间格式转换—将后台返回的/Date(1448954018000)/格式转换为正常的时间格式
  4. 【MySQL】函数IFNULL、设置默认时间
  5. 【WPF】WPF 布局
  6. css3-无缝滚动
  7. 43. Multiply Strings
  8. html5定位getLocation()
  9. CVE-2016-1240 Tomcat 服务本地提权漏洞
  10. System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本问题