Intuition for why/how $\delta \int_A^B n(\mathbf{r}) \ ds = 0$? My textbook, Fundamentals of Photonics, 3rd edition, by Teich and Saleh, says the following:

Fermat's Principle. Optical rays travelling between two points, $A$ and $B$, follow a path such that the time of travel (or the optical pathlength) between the two points is an extremum relative to neighboring paths. This is expressed mathematically as
$$\delta \int_A^B n(\mathbf{r}) \ ds = 0, \tag{1.1-2}$$
where the symbol $\delta$, which is read "the variation of," signifies that the optical pathlength is either minimized or maximized, or is a point of inflection. ...

This probably doubles as a mathematics question, but I'm going to ask it here anyway.
How does the fact that the optical rays follow a path such that the time of travel (optical pathlength) between two points is an extremum relative to neighboring paths imply the result $\delta \int_A^B n(\mathbf{r}) \ ds = 0$? I'm struggling to develop an intuition for why/how the "variation of" optical pathlength would be $0$ in this case.
I would greatly appreciate it if people could please take the time to clarify this.
 A: A variation is a fancy derivative.  If you start with the integral
$$
I=\int_A^B f(x,x')dx
$$
one first makes this into a parametrized integral 
$$
I(\epsilon)=\int_A^B f(x(\epsilon),x'(\epsilon))dx
$$
with $x(\epsilon)$ and $x'(\epsilon)$ "parametrized path" so that the true path is at $\epsilon=0$.  Then $\delta I=\frac{d}{d\epsilon}I(\epsilon)=0$.  
When looking for points where a function $g$ is extremal, the condition $d g/dx=0$ provides an algebraic equation to find the points $x_0$ where $g$ is extremal.  
For the integral $I$, we're not looking points where the integral is extremal; instead the variation $\delta I=0$ provides a differential equation to be satisfied by the function $f(x,x')$ (here this function is the path of light) that produces an extremum of the integral.
So Fermat's principle states the path to travel from $A$ to $B$ will be such that the total time $\int_A^B dt= \int_A^B n ds$ is extremal, i.e. if you pick any neighbouring path, the time will be longer (assuming the extremum is a minimum).  
This is certainly true when the index $n$ is constant: the path is then a straight line between $A$ and $B$; since the straight line is the path between two points, the time taken for light travelling at constant speed (since $n$ is constant) is minimum, i.e. $\delta I=0$.
In more general cases the index will not be constant so the more general integral $\int_A^B n(s) ds$ is the general way of obtaining the total travel time.  
For an excellent discussion see: Boas, Mary L. Mathematical methods in the physical sciences. John Wiley & Sons, 2006.
