This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes Hi I need shortestpath algorithm in java program for runtime inputs....... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Hi I need shortestpath algorithm in java program for runtime inputs......." Watch "Hi I need shortestpath algorithm in java program for runtime inputs......." New topic
Author

Hi I need shortestpath algorithm in java program for runtime inputs.......

harikrishnan venkatesan
Greenhorn

Joined: Jul 06, 2012
Posts: 7
HI ,

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
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38472
    
  23
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.
 
 
subject: Hi I need shortestpath algorithm in java program for runtime inputs.......