First of all, it should be explained that the search algorithm is essentially an enumeration, time complexity is still very high, encountered problems (especially in the level of the game), do not prioritize the use of search algorithms.
Here's a summary of the DFS algorithm:
1. Start at a vertex and Access v.
2. Locate the first inaccessible adjacency point of the vertex you have just visited, and access the vertex. Repeat this step with the vertex as a new vertex, until the vertex you just accessed has no adjacency points that have not been visited.
3. Returns the vertex of the previous visited Adjacency point that has not been visited, and finds the next inaccessible adjacency point of the vertex, accessing the vertex.
4, repeat 2, 3, until all vertices in the graph have been accessed, the search is over.
The key to understanding depth-first search is to solve the "What to do Now". As for "What to do next" is the same as "what to do Now". For example, the main problem with DFS functions is that when you go to step one, the usual approach is to make every possible
Try again (for loop implementation), the current step is resolved and then go to the next DFS (STEP+1);
Let's start with a licensed DFS template exercise: http://www.cnblogs.com/wenzhixin/p/7412323.html
Then we'll practice. Using the DFS algorithm to solve the problem of coloring the link area in the graph: http://www.cnblogs.com/wenzhixin/p/7271071.html
Finally look at the typical topic of DFS search: http://www.cnblogs.com/wenzhixin/p/7268017.html
Finally summed up, in fact, the search of the topic, in some of the level of the game is difficult, often using dynamic planning or find the law, not the last resort or not to use this violent search (except for efficient pruning).
DFS algorithm (--template exercises and summary)