4 ms·
Just take Dijkstra's Algorithm (or possibly A* if you want to try to optimize the runtime performance) and give a higher cost to edges in your map that correspo
by Figs 15y ago
Just take Dijkstra's Algorithm (or possibly A* if you want to try to optimize the runtime performance) and give a higher cost to edges in your map that correspond to left turns. Now it's just a matter of tuning the additional weight added to suit your preference. You won't get the shortest distance any more, just the "cheapest" path in terms of the distance/left-turn weight; if you find you have to go too far out of your way to avoid left turns, you may want to reduce the added weight so you can make a few more left turns without going so far away. For example, you probably don't want to go 10 miles down the freeway and another 10 back to avoid a single left turn on what would otherwise be a 5 minute drive, but maybe you'd instead be willing to drive a 1/2 mile to avoid a left turn that you'd otherwise have had routed -- so route the left turn as whatever distance it would be plus 1/2 mile additional cost.