-
Notifications
You must be signed in to change notification settings - Fork 0
updatePollution()
In the industrial class definition, there is a function call in which, from the industrial node in which it's called, recursive BFS is used to set the pollution of surrounding zones.
From the main function, the updatePollution function is called on the list of all industrial zones in the master list z_list. The origin node, a queue containing the origin node, and a discovered 2D vector are passed into the function from main() for each call.
The function works as follows:
-
Base case: If the queue is empty, return up the stack.
-
Normal case: The front of the list is set to the current zone, and the front is popped. If the current zone is the origin (happens only once) the pollution value of that zone is set equal to the zone's current population. If the current zone is not the origin zone, each undiscovered adjacency's pollution value is set to the value of the current zone's pollution -1, and then added to the discovery queue and marked on the discovery 2D vector as discovered.
This implementation effectively and concisely ensures the pollution radiates outward appropriately from all industrial zones.