title: Avoid u-turns in A* algorithm
body: <p>I have defined nodes and edges for a graph, which I want to use to resolve pathfinding using the A* algorithm. I have an A* algorithm that seems to work but I now need to prevent u-turns. These aren't 2 or more lanes roads, these are single direction only, although two nodes form two edges (one in either direction).</p>
  
  <p>So, for example, if I want to calculate the route from 1114-1105, the algorithm gives me 1114-1112-1105. This is invalid as it involves a u-turn from 1112 to 1105. The result I want to achieve would be more like 1114-1110-1111-1113-1112-1105.</p>
  
  <p>I naively thought I could calculate the angle between the previous, current and next nodes, which in this case would be 0 and then add a large number to the 'f' value. But this doesn't seem to do anything.</p>
  
  <p>Any suggestions for how to implement this? Thanks</p>
  
  <p><a href="https://i.stack.imgur.com/P90u9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P90u9.png" alt="Example graph"></a></p>