Searches for a better (more parsimonious) tree by swapping the relative positions of subtrees separated by one edge. At each inner edge (i.e. at non-leaf edges) three different topologies are possible.
Testing these 3 possible topologies and keeping the best of them, is called "Nearest Neighborhood Interchange" (NNI).
Possible topologies tested by NNI
The 3 different topologies checked by performing a NNI are
(A,B,C = subtrees; R = rest of tree)
R R R
\ \ \
/\ /\ /\
A \ B \ C \
/\ /\ /\
B C A C B A
Note: there are no other possible topologies containing A,B,C and R!