I have been using networkX to compute the shortest path distance between two points A and B in a graph thanks to Dijkstra's algorithm. The edges of my graph represent road segments, and the nodes the connections between segments. The weight function is the segment length, so that the returned path distance is the actual geographical distance.
However, the calculated paths are sometimes unrealistic for my use. More specifically, I would like to prevent the algorithm from using paths implying very sharp turns between two successive edges. This implies that the weight of a particular edge is a function of the edge itself, but also of its precedessor in the path (so that the turn angle can be computed and sharp turns dismissed).
As a (simplistic) example, let's consider the below graph (assuming that the nodes and represented according to their actual geographical position). For the sake of simplicity, each edge has a weight (or distance) equal to 1. The shortest path from A to B is shown in green, and the corresponding distance is 2.
Shortest path without "sharp turn" constraint

However, the proposed path involve a sharp turn at node C (which can be detected based on the geographical coordinates of nodes A, B and C). This kind of turn should be forbidden, such that the proposed shortest path becomes the one described below.
Shortest path with "sharp turn" constraint

The distance is now 6, but the path avoids the transition A-B-C which involved a sharp turn.
What do you think are my options to implement such requirement?