That would be rather unfair to the railways as well. Unlike roads, railway routes cannot follow the shortest distance always. And running a train through a round about route is to provide more coverage and serve other passengers as well. So, indirectly the end-to-end passengers will be travelling through a longer route for the sake of other intermediate passengers and not due to some lapse or fault from the railways side. That way, going by a system of kilometer slabs, the passengers will not be grossly overcharged (compared to charging per kilometer for the displacement between the two cities).