Verbatim! In the main do/while loop, the heap is growing by 2 every pass. Is it possible that the code posted online has a defect? Could you post your sample code you are running as a compressed attachment? Thanks!
Data Structures: Dijkstra's Algorithm
#17
Posted 27 June 2011 - 11:38 AM
My code is on my home computer. I'll check later tonight and see what's going on. It's possible I accidentally posted an old version, but I'm pretty sure this is the most recent one.
#18
Posted 27 June 2011 - 12:07 PM
I'm fairly sure that the posted code doesn't have any support for detecting Vertexes (Connections) that have already been visited and it immediately get's into an inf-loop. I added support for marking Connections as having been visited and think I have a solution. I would be very interested in seeing yours to make sure I have optimized this. Thanks!
#19
Posted 27 June 2011 - 02:24 PM
It looks like I made some changes to my Edge class in my Graphs tutorial for some other stuff I did. I updated it in my Graphs tutorial. Try again. You should be good to go.
#20
Posted 23 November 2011 - 09:45 PM
Sorry to bring this post back to life, but been looking over the code for a bit and been trying to figure this out. Is there any way for the program to return the path that was taken to the shortest root? For example if the command was
to output: i,k.n = 11
Thank you for your help, and sorry
test.heapPath(i, n);
to output: i,k.n = 11
Thank you for your help, and sorry
#21
Posted 01 December 2011 - 07:53 PM
You could have an array of size V. Obviously the starting and ending points would be the first and last elements. But once you find the closest Vertex from the starting point, you would update the appropriate position in the array. Follow along this train of logic for each individual Vertex.
|
|






MultiQuote



|