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

前端 未结 3 509
不思量自难忘°
不思量自难忘° 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:44

    The JDK does not provide an implementation of the Fibonacci Heap. You will have to create your own implementation, or you can find one in this post: Fibonacci Heap

    All you have to afterwards is replacing

    PriorityQueue vertexQueue = new PriorityQueue<>();
    

    by

     FibonacciHeap vertexQueue = new FibonacciHeap<>();
    

    Then simply change the calls to thepoll, add and remove methods with their equivalent in your provided implementation.

提交回复
热议问题