This week's giveaway is in the Groovy forum. We're giving away four copies of Groovy Fundamentals video training course and have Ken Kousen on-line! See this thread for details.

I need shortest path algorithm in java program code with simplest method.. for all usiing runtime inputs.. Already I am tried for one program in java.. its for static inputs.. i cant get dynamic input for shortest path for this given program.. please can anyone help to update the program or give the new program method in java....

my static inputs shortestpath find program in java..

outputs::::

main method: --------------->
Edge method called: --------------->
target and weight: --------------->Blueville,10.0
Edge method called: --------------->
target and weight: --------------->Greenville,2.0
Edge method called: --------------->
target and weight: --------------->Orangeville,8.0
Edge method called: --------------->
target and weight: --------------->Redvile,10.0
Edge method called: --------------->
target and weight: --------------->Greenville,3.0
Edge method called: --------------->
target and weight: --------------->Purpleville,7.0
Edge method called: --------------->
target and weight: --------------->Redvile,2.0
Edge method called: --------------->
target and weight: --------------->Blueville,3.0
Edge method called: --------------->
target and weight: --------------->Redvile,8.0
Edge method called: --------------->
target and weight: --------------->Purpleville,2.0
Edge method called: --------------->
target and weight: --------------->Blueville,7.0
Edge method called: --------------->
target and weight: --------------->Orangeville,2.0
computePaths: --------------->
vertexQueue: --------------->[Redvile]
inside vertexQueue is: --------------->[Redvile]
uValue = vertexQueue.poll() values is: --------------->Redvile
Inside For Each-----The distanceThroughU and v.minDistance is: 10.0,Infinity
Inside if condition--->
Inside For Each-----The distanceThroughU and v.minDistance is: 2.0,Infinity
Inside if condition--->
Inside For Each-----The distanceThroughU and v.minDistance is: 8.0,Infinity
Inside if condition--->
inside vertexQueue is: --------------->[Greenville, Blueville, Orangeville]
uValue = vertexQueue.poll() values is: --------------->Greenville
Inside For Each-----The distanceThroughU and v.minDistance is: 4.0,0.0
Inside For Each-----The distanceThroughU and v.minDistance is: 5.0,10.0
Inside if condition--->
inside vertexQueue is: --------------->[Blueville, Orangeville]
uValue = vertexQueue.poll() values is: --------------->Blueville
Inside For Each-----The distanceThroughU and v.minDistance is: 15.0,0.0
Inside For Each-----The distanceThroughU and v.minDistance is: 8.0,2.0
Inside For Each-----The distanceThroughU and v.minDistance is: 12.0,Infinity
Inside if condition--->
inside vertexQueue is: --------------->[Orangeville, Purpleville]
uValue = vertexQueue.poll() values is: --------------->Orangeville
Inside For Each-----The distanceThroughU and v.minDistance is: 16.0,0.0
Inside For Each-----The distanceThroughU and v.minDistance is: 10.0,12.0
Inside if condition--->
inside vertexQueue is: --------------->[Purpleville]
uValue = vertexQueue.poll() values is: --------------->Purpleville
Inside For Each-----The distanceThroughU and v.minDistance is: 17.0,5.0
Inside For Each-----The distanceThroughU and v.minDistance is: 12.0,8.0

After Finish The computePaths Method(Vertex source) is :
Inside For Loop is........Distance to Redvile: 0.0
The getShortestPathTo is------>
Path: [Redvile]
Inside For Loop is........Distance to Blueville: 5.0
The getShortestPathTo is------>
Path: [Redvile, Greenville, Blueville]
Inside For Loop is........Distance to Greenville: 2.0
The getShortestPathTo is------>
Path: [Redvile, Greenville]
Inside For Loop is........Distance to Orangeville: 8.0
The getShortestPathTo is------>
Path: [Redvile, Orangeville]
Inside For Loop is........Distance to Purpleville: 10.0
The getShortestPathTo is------>
Path: [Redvile, Orangeville, Purpleville]

note:------------------------------------------------------------> please anyone help me for update this program for dynamic inputs and post here or mail me as soon as possible ...... vhkrishnan.v@gmail.com

So, what is the algorithm? There is no point in learning algorithms off by heart, unless you have to sit an exam. Write down the algorithm on paper, and reduce it to really simple terms. Then you can easily program it.

By the way, I had to insert new lines because your code lines are too long to read easily. You also have inconsistent spacing (one space each side of +, please, for example), and don’t use tabs for indenting.