Java: Using a Fibonacci Heap for Implementing Dijkstra's Algorithm

前端 未结 3 492
不思量自难忘°
不思量自难忘° 2021-01-03 13:56

New here, but have been lurking as a guest for quite some time :)

Okay, so I\'ve been trying to do Dijkstra\'s shortest path algorithm using a Fibonacci heap (in Jav

3条回答
  •  一生所求
    2021-01-03 14:38

    It seems you are missing to add all the nodes the your heap with Double.POSITIVE_INFINITY (except the source node with 0.0 distance). That's why you are having NullPointerExceptions, they are simply not in the heap.

    I made some test on several open-source Fibonacci Heap implementation. You can find the test itself here: Experimenting-with-dijkstras-algorithm. Also this is my Priority Queue version of the Dijsktra's algorithm: PriorityQueueDijkstra.java

提交回复
热议问题