Shader - Spread Color from one Vertex to all the other ones in Breadth First Fashion

Hello everyone,

I am attempting to create a particle system (THREE.Points) in which every particles resembles a firefly. Okay, simple. Now, I want to create an animation in which one particle / vertex is chosen at random, shifts colors, and then spreads that color to the neighboring particles - in a breadth first search way. So if particle A is the selected one and of equal distance to particles B, C, D, E, F, then all of those light up / change colors afterwards, which then leads to the neighboring particles of B, C, D, E, F to light up / change colors until all of the particles have been modified once. Cool.

Onto my question, I am exploring achieving such an effect in two ways:

  1. Through the CPU / JS, by simply selecting a point / vertex / particle at random and then using a function to see which one are the closest, adding those to a queue, changing their color, and repeating the same method / loop until all particles have had their color modified.

  2. Doing so through the fragment shader. I know that shaders take advantage of the GPU’s parallel processing, I am simply haven’t figured out yet how to trigger such an animation.

Which one would you recommend for my purpose?