In general, DFS and BFS are a traversal strategy, and the framework of the overall operation is fixed, but the specific processing and the formal parameters of the function need to be specific to the specific problem.
In other words, in the BFS or DFS, the first thing to understand is: what is the purpose of the traversal. Tag nodes have been accessed (must have in any topic) calculation parameters during traversal (selection)
Calculating parameters is a more common topic, and only the nodes are evaluated when the number of connected blocks is calculated.
Describe the problem of calculation parameters in detail.
Parameter references can be used in formal parameters, which is equivalent to calculation, because the outside can feel the change, DFS uses more, because DFS is recursive processing.
or define global variables, the function changes directly, this only BFS more use, because BFS is a cyclic processing.
DFS still needs to pay more attention to the method of recursive function, that is to note: The recursive boundary of the current layer of logical processing recursive method