Trying to Achieve a Chain of Moving Connected Circles (and stop it)

Hi everyone, I have this quite complex problem: I have a fixed array of circles and another big circle in the center of the screen. When a circle from the array is near the big one, the one from the array starts to move (like if the big one is the engine). I can add circles from the array to the one connected with the big one, and those start moving too.
The problem is: I want that when i detach the nearest circle from the engine, all the circles connected with this one stop. That means: transmit the movement from the engine to the chain of circles. I’m trying to use a adjacent list, in order to achieve the information if some circle is connected to the engine.
That is the thing:

My suggestion would be for each object in your list, iterate over all the other objects in that same list. Check for distanceSquared() <= radius * radius to see if they’re touching, and also make sure you don’t check objects with themselves.

You can then write some logic for what happens if one object is touching another. It’ll be more or less complicated depending on what behavior you want and how you architecture your code.