An algorithm is suggested for the calculation of the reaction distance as the minimal number of elementary steps of reorganization of valence electrons during a reaction. The basis for the formulation of this algorithm is the synthon isomerization graph (SR-graph). Chemical examples of application of the algorithm are given.