In an electric power system, slow coherency can be applied to identify groups of the generating units, the rotors of which are swinging together against each other at approximately the same oscillatory frequencies of inter-area modes. This serves as a prerequisite-step of several emergency control schemes to identify power system control areas and improve transient stability. In this paper, slow coherent generators are grouped based on the direction and the strength of electromechanical coupling between different generators. The proposed algorithm performs low-pass filtering of generator frequency measurements. It adaptively determines the minimal number of the measurements to be processed in an observation window, and performs data selectivity to prevent mixing of interfering coherency indices. Finally, it adaptively tracks grouping changes of slow coherent generators and determines a finite number of groups for an improved affinity propagation clustering. The proposed algorithm is implemented as an online MATLAB program and verified in real-time using RTDS power system simulator with the integration of actual synchronized measurement technology components as hardware-in-the-loop. The obtained results demonstrate the effectiveness of the proposed algorithm for robust and near real-time identification of grouping changes of slow coherent generators during the quasi-steady-state and electromechanical transient period following a disturbance.