The algorithm implemention is shown in the figure below:
There are 4 functional blocks as shown in the figure:
- GetVertex is responsible to load the next vertex in the queue and pass it to the ReadGraph.
- ReadGraph collects all next hop vertices and pass them to the next module.
- ReadColor check each next hop vertex whether it has already been discovered in ealier stages of the BFS. This module only passes first discovered vertices to the next block.
- When the 3rd functional block ends, WriteRes update the discovery, finish, level and parent value accordingly. And also this block push all the vertices collected from block 3 into Queue.
This system starts from pushing the source vertex into the queue and iterate until the queue is empty.