A connected component-based method for efficiently integrating multi-scale N-body systems