Quote:
Originally Posted by ddebbie90
For example, i am in a node that is connected to the node i want to go, but because the edge has more weight than another edge to a node that is not connected to the node i want to go, the algorithm follows the wrong path.
|
If I understand what you just wrote, then that is correct behavior.
Assume you are at node A and your destination is B.
There is an edge of cost 6 from A to B.
There is an edge of cost 2 from A to C.
There is an edge of cost 1 from C to D.
There is an edge of cost 2 from D to B.
So the low cost path from A to B is through C.
When you are at A, you don't know whether that path from C to B exists. So the search algorithm correctly tries C first to see if such a path exists.
If there isn't an optimal path through C, the algorithm will later find the direct path from A to B.