Is there a way to count the number of turns that were traversed by the shortest route, and to write this number to the output table of the o-d matrix solver or of the shortest route solver?
What is a "turn" in your definition?
If you do a shortest path between two stops, then you can use the Copy Traversed Source Features to write out Edges, Junctions, Turns that were traversed by that route. Note the "turns" here mean actual turn features that may have been digitized into the network dataset. You can use the Edges and Junctions feature classes to "count" the turns you are interested. Note that the Copy Traversed Source Features tool does not work with OD Cost Matrix solver as that solver does not need to generate output shape geometries and does not keep track of this information.
Copy Traversed Source Features—Help | ArcGIS Desktop
This post is connected to my parallel post "Manipulating waiting times with script elevators", i.e. the turns (again) represent airports, which means the turns represent network nodes, junctions and turns at the same time. Having reviewed the result table of the Copy Traversed Source Features tools (the turns table), applied on the routes generated by the Closest Facility solver, it seems that the table only creates entries for such pair of airports, which can only be reached via connecting flights. For airport pairs that are connected by direct flights, no entries where generated in the turns table. This is, however, what I was looking for at the moment.
Retrieving data ...