1

I have been reading up about path finding and find it all very confusing, however this is probably the best I have found for a logical explanation:

Path

If the cost of two nodes has the same value, I'm not sure how the path would be worked out though. How would it be worked out?

Dave
  • 480
  • 8
  • 20

1 Answers1

5

If two paths have the same value then it doesn't matter which one you pick. There may be multiple paths with the same distance, but you're only concerned with a single one.

In that example diagram it uses < for the comparison, which means the earliest shortest path found will be chosen over latter ones.

Pubby
  • 699
  • 4
  • 9
  • Yeh but its only shortest in that moment, it could Infact take longer later on if you blindly follow the shortest path initially surely? So wouldn't you have to some how go back on yourself or something – Dave Apr 17 '12 at 04:07
  • @Dave If there's a shorter path then it gets replaced by it. I'm only talking about when they have the same value. – Pubby Apr 17 '12 at 04:08
  • Well yeh but if you find 2 nodes with same values, you have to pick at random pretty much so if you found the end for one node took 10 steps... how do you know if the other was any shorter =/ – Dave Apr 17 '12 at 04:11
  • 6
    The algorithms do not just pick a way and go with it. They do all of them until the destination is reached. That's when the shortest path is returned. – House Apr 17 '12 at 04:12