Good code is its own best documentation. As you are about to add a comment, ask yourself, How can I improve the code so that this comment isn't needed? Improve the code and then document it to make it even clearer. Steve McConnell

Dijkstra Algorithm

Language Java | Level Intermediate | Category Data structure | September 9, 2015 9:52 am


Data structure Description

Dijkstra's algorithm is an algorithm for finding the shortest paths between nodes in a graph.

Write a program to implement the Dijkstra Algorithm


Output

   					 

Distance to Mumbai: 0.0
Path: [Mumbai]
Distance to Chennai: 5.0
Path: [Mumbai, Chennai]
Distance to Bangalore: 8.0
Path: [Mumbai, Chennai, Bangalore]
Distance to Hyderabad: 8.0
Path: [Mumbai, Hyderabad]
Distance to Coimbatore: 10.0
Path: [Mumbai, Hyderabad, Coimbatore]

				    

Comments


No comments available!

Please login to add comments.