Skip to content

Instantly share code, notes, and snippets.

@pavloo
Last active August 7, 2019 10:31
Show Gist options
  • Save pavloo/5a8dea6cc771724a8e3102677466dd3c to your computer and use it in GitHub Desktop.
Save pavloo/5a8dea6cc771724a8e3102677466dd3c to your computer and use it in GitHub Desktop.
Step # Illustration State of Queue Pool of workers Description
1 Alt text 1, r,y,g,b Initial state, node 1 is scheduled for processing
2 Alt text y,g,b Red worker pops up node 1 from the queue and processes it
3 Alt text 2,3, r,y,g,b Red worker finishes with node 1 and pushes all adjacent nodes to the queue
4 Alt text r,b Green and Yellow workers pop up from the queue and process node 2 and node 3
5 Alt text 5, r,y,b Yellow worker finishes processing node 3 and pushes all it's adjacent nodes (it's a single node 5 though) to the queue. Node 3 is still under processing with Green worker.
6 Alt text r,y Blue worker pops up node 5 from the queue and starts processing it
7 Alt text 6, r,y,b Blue worker finishes processing node 5 and pushes node 6 to the queue
8 Alt text y,b Red worker pops up node 6 and attempts processing it
9 Alt text r,y,b Red worker checked if all the nodes that have path to *node 6* were already processed, and nodes *2* and *4* didn't fall into that category, so Red worker simply returns to the pool without processing *node 6*
10 Alt text 4 r,y,g,b Green worker finally finishes processing node 3 and pushes node 4 to the queue
11 Alt text r,g,b Yellow worker pops up node 4 and starts processing it
12 Alt text 6 r,y,g,b Yellow worker finishes processing node 4 and pushes node 6 to the queue
13 Alt text r,y,b Green worker pops up node 6 and starts processing it
14 Alt text 7,8,9 r,y,g,b Green worker finishes processing node 6 and adds all it's adjacent nodes to the queue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment