My understanding is that the path of a photon between any two points A and B can be worked out by finding the route which will get it there in the least time. This seems to be true both when a photon passes near a heavy mass and deviates because of gravity (as predicted by general relativity) and when it travels through different media and is refracted (as predicted by classical optics). I don’t know why this would be the case, but, intuitively, it seems like it should be something fundamental about the nature of space-time. Is it? Or is it just a coincidence? Or am I just wrong?