P: n/a

This is probably a bit OT, as I'm not looking for a c++ implementaiton of
Dijkstra's algorithm, rather I'm just trying to understand it (is there a
better place then here to ask this question?). I've reviewed several sites
and the faq (no, I'm not asking you to do my homework for me) and the
examples don't give me the information I need to continue on. I'm working
with a complex tree, and am not sure how to logically apply Dijkstra's
algorithm to it. This is how I understand it in my own words:
Let's say I start at A, and the adjacent vertex with the least weight is
AB, and the weight of the edge is 5.
A5 B
From here, there are only 3 places I can go as follows:
A6C
A5B2D
A5B3E
From AC is 6, from ABD is 7, from ABE is 8. The next shortest path is
from AC for a total of 6, not ABD or ABE.
D for a total of 7 or 8. Here is where I'm confused: does my second step
have to be a continuation of the first step, IOW can I only go from B to the
next unused vertex, or should I select the next unused vertex adjacent to a
used vertex that gives me the leasted cumulative weight? If the latter, then
I should choose AC for 6, then ABD for 7, and lastly ABE for 8. At each
stop, I look at all adjacent nodes and fill in the lessor of the already
figured distance to the node, and the distance from the node I stopped at to
that node. If I do this, I eventually get what I believe is the shortest
path to my destination, but I'm not sure I did it right.  
Share this Question
P: n/a

Ook wrote: This is probably a bit OT, as I'm not looking for a c++ implementaiton of Dijkstra's algorithm, rather I'm just trying to understand it (is there a better place then here to ask this question?).
comp.programming comes to mind as one option
I've reviewed several sites and the faq (no, I'm not asking you to do my homework for me) and the examples don't give me the information I need to continue on. I'm working with a complex tree, and am not sure how to logically apply Dijkstra's algorithm to it. This is how I understand it in my own words:
Let's say I start at A, and the adjacent vertex with the least weight is AB, and the weight of the edge is 5.
A5 B
From here, there are only 3 places I can go as follows:
A6C A5B2D A5B3E
From AC is 6, from ABD is 7, from ABE is 8. The next shortest path is from AC for a total of 6, not ABD or ABE. D for a total of 7 or 8. Here is where I'm confused: does my second step have to be a continuation of the first step, IOW can I only go from B to the next unused vertex,
no
or should I select the next unused vertex adjacent to a used vertex that gives me the leasted cumulative weight?
yes
If the latter, then I should choose AC for 6, then ABD for 7, and lastly ABE for 8.
Certaintly choose AC for 6. Then you update the distances based on
having made that choice and choose the next closest item (which may be
ABD for 7 or may be something else which becomes closer by virtue of
the path through C).
At each stop, I look at all adjacent nodes and fill in the lessor of the already figured distance to the node, and the distance from the node I stopped at to that node. If I do this, I eventually get what I believe is the shortest path to my destination, but I'm not sure I did it right.
That is the basic idea of the algorithm. (But bear in mind that it
doesn't work if any edge has negative length.)  
P: n/a
 comp.programming comes to mind as one option
Thanks, I'll try there :)
or should I select the next unused vertex adjacent to a used vertex that gives me the leasted cumulative weight?
yes
That is what I was missing. Most of the explanations I've seen seem to
assume you already know how it works, and don't clearly explain it. :P  
P: n/a

Matthew L Reed wrote: comp.programming comes to mind as one option
Thanks, I'll try there :)
or should I select the next unused vertex adjacent to a
used vertex that gives me the leasted cumulative weight?
yes
That is what I was missing. Most of the explanations I've seen seem to assume you already know how it works, and don't clearly explain it. :P
I'd say find a better explanation, as there are good ones out there.
"Introduciton to Algorithms" by Cormen et al. is one example.   This discussion thread is closed Replies have been disabled for this discussion.   Question stats  viewed: 4574
 replies: 3
 date asked: Dec 13 '05
