According to Fermat's principle, ray of light would follow that path put of many paths joining two points like A and B for which the time taken is minimum.